1
0
Fork 0

soc: fsl: dpio: Add Support for Order Restoration

Add DPIO support for HW assisted order restoration

Signed-off-by: Roy Pledge <roy.pledge@nxp.com>
5.4-rM2-2.2.x-imx-squashed
Roy Pledge 2017-10-04 15:36:06 -04:00 committed by Dong Aisheng
parent 4820cd6245
commit d8cfff8022
4 changed files with 158 additions and 1 deletions

View File

@ -707,3 +707,108 @@ int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid, u32 *num)
return 0;
}
EXPORT_SYMBOL_GPL(dpaa2_io_query_bp_count);
/**
* dpaa2_io_service_enqueue_orp_fq() - Enqueue a frame to a frame queue with
* order restoration
* @d: the given DPIO service.
* @fqid: the given frame queue id.
* @fd: the frame descriptor which is enqueued.
* @orpid: the order restoration point ID
* @seqnum: the order sequence number
* @last: must be set for the final frame if seqnum is shared (spilt frame)
*
* Performs an enqueue to a frame queue using the specified order restoration
* point. The QMan device will ensure the order of frames placed on the
* queue will be ordered as per the sequence number.
*
* In the case a frame is split it is possible to enqueue using the same
* sequence number more than once. The final frame in a shared sequence number
* most be indicated by setting last = 1. For non shared sequence numbers
* last = 1 must always be set.
*
* Return 0 for successful enqueue, or -EBUSY if the enqueue ring is not ready,
* or -ENODEV if there is no dpio service.
*/
int dpaa2_io_service_enqueue_orp_fq(struct dpaa2_io *d, u32 fqid,
const struct dpaa2_fd *fd, u16 orpid,
u16 seqnum, int last)
{
struct qbman_eq_desc ed;
d = service_select(d);
if (!d)
return -ENODEV;
qbman_eq_desc_clear(&ed);
qbman_eq_desc_set_orp(&ed, 0, orpid, seqnum, !last);
qbman_eq_desc_set_fq(&ed, fqid);
return qbman_swp_enqueue(d->swp, &ed, fd);
}
EXPORT_SYMBOL(dpaa2_io_service_enqueue_orp_fq);
/**
* dpaa2_io_service_enqueue_orp_qd() - Enqueue a frame to a queueing destination
* with order restoration
* @d: the given DPIO service.
* @qdid: the given queuing destination id.
* @fd: the frame descriptor which is enqueued.
* @orpid: the order restoration point ID
* @seqnum: the order sequence number
* @last: must be set for the final frame if seqnum is shared (spilt frame)
*
* Performs an enqueue to a frame queue using the specified order restoration
* point. The QMan device will ensure the order of frames placed on the
* queue will be ordered as per the sequence number.
*
* In the case a frame is split it is possible to enqueue using the same
* sequence number more than once. The final frame in a shared sequence number
* most be indicated by setting last = 1. For non shared sequence numbers
* last = 1 must always be set.
*
* Return 0 for successful enqueue, or -EBUSY if the enqueue ring is not ready,
* or -ENODEV if there is no dpio service.
*/
int dpaa2_io_service_enqueue_orp_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
u16 qdbin, const struct dpaa2_fd *fd,
u16 orpid, u16 seqnum, int last)
{
struct qbman_eq_desc ed;
d = service_select(d);
if (!d)
return -ENODEV;
qbman_eq_desc_clear(&ed);
qbman_eq_desc_set_orp(&ed, 0, orpid, seqnum, !last);
qbman_eq_desc_set_qd(&ed, qdid, qdbin, prio);
return qbman_swp_enqueue(d->swp, &ed, fd);
}
EXPORT_SYMBOL_GPL(dpaa2_io_service_enqueue_orp_qd);
/**
* dpaa2_io_service_orp_seqnum_drop() - Remove a sequence number from
* an order restoration list
* @d: the given DPIO service.
* @orpid: Order restoration point to remove a sequence number from
* @seqnum: Sequence number to remove
*
* Removes a frames sequence number from an order restoration point without
* enqueing the frame. Used to indicate that the order restoration hardware
* should not expect to see this sequence number. Typically used to indicate
* a frame was terminated or dropped from a flow.
*
* Return 0 for successful enqueue, or -EBUSY if the enqueue ring is not ready,
* or -ENODEV if there is no dpio service.
*/
int dpaa2_io_service_orp_seqnum_drop(struct dpaa2_io *d, u16 orpid, u16 seqnum)
{
struct qbman_eq_desc ed;
struct dpaa2_fd fd;
d = service_select(d);
if (!d)
return -ENODEV;
qbman_eq_desc_clear(&ed);
qbman_eq_desc_set_orp_hole(&ed, orpid, seqnum);
return qbman_swp_enqueue(d->swp, &ed, &fd);
}
EXPORT_SYMBOL_GPL(dpaa2_io_service_orp_seqnum_drop);

View File

@ -413,6 +413,43 @@ void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success)
d->verb |= enqueue_rejects_to_fq;
}
/**
* qbman_eq_desc_set_orp() - Set order-restoration in the enqueue descriptor
* @d: the enqueue descriptor.
* @response_success: 1 = enqueue with response always; 0 = enqueue with
* rejections returned on a FQ.
* @oprid: the order point record id.
* @seqnum: the order restoration sequence number.
* @incomplete: indicates whether this is the last fragments using the same
* sequence number.
*/
void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success,
u16 oprid, u16 seqnum, int incomplete)
{
d->verb |= (1 << QB_ENQUEUE_CMD_ORP_ENABLE_SHIFT);
if (respond_success)
d->verb |= enqueue_response_always;
else
d->verb |= enqueue_rejects_to_fq;
d->orpid = cpu_to_le16(oprid);
d->seqnum = cpu_to_le16((!!incomplete << 14) | seqnum);
}
/**
* qbman_eq_desc_set_orp_hole() - fill a hole in the order-restoration sequence
* without any enqueue
* @d: the enqueue descriptor.
* @oprid: the order point record id.
* @seqnum: the order restoration sequence number.
*/
void qbman_eq_desc_set_orp_hole(struct qbman_eq_desc *d, u16 oprid,
u16 seqnum)
{
d->verb |= (1 << QB_ENQUEUE_CMD_ORP_ENABLE_SHIFT) | enqueue_empty;
d->orpid = cpu_to_le16(oprid);
d->seqnum = cpu_to_le16(seqnum);
}
/*
* Exactly one of the following descriptor "targets" should be set. (Calling any
* one of these will replace the effect of any prior call to one of these.)

View File

@ -167,6 +167,9 @@ int qbman_result_has_new_result(struct qbman_swp *p, const struct dpaa2_dq *dq);
void qbman_eq_desc_clear(struct qbman_eq_desc *d);
void qbman_eq_desc_set_no_orp(struct qbman_eq_desc *d, int respond_success);
void qbman_eq_desc_set_orp(struct qbman_eq_desc *d, int respond_success,
u16 oprid, u16 seqnum, int incomplete);
void qbman_eq_desc_set_orp_hole(struct qbman_eq_desc *d, u16 oprid, u16 seqnum);
void qbman_eq_desc_set_token(struct qbman_eq_desc *d, u8 token);
void qbman_eq_desc_set_fq(struct qbman_eq_desc *d, u32 fqid);
void qbman_eq_desc_set_qd(struct qbman_eq_desc *d, u32 qdid,

View File

@ -1,7 +1,7 @@
/* SPDX-License-Identifier: (GPL-2.0+ OR BSD-3-Clause) */
/*
* Copyright 2014-2016 Freescale Semiconductor Inc.
* Copyright NXP
* Copyright 2017 NXP
*
*/
#ifndef __FSL_DPAA2_IO_H
@ -121,6 +121,18 @@ struct dpaa2_io_store *dpaa2_io_store_create(unsigned int max_frames,
void dpaa2_io_store_destroy(struct dpaa2_io_store *s);
struct dpaa2_dq *dpaa2_io_store_next(struct dpaa2_io_store *s, int *is_last);
/* Order Restoration Support */
int dpaa2_io_service_enqueue_orp_fq(struct dpaa2_io *d, u32 fqid,
const struct dpaa2_fd *fd, u16 orpid,
u16 seqnum, int last);
int dpaa2_io_service_enqueue_orp_qd(struct dpaa2_io *d, u32 qdid, u8 prio,
u16 qdbin, const struct dpaa2_fd *fd,
u16 orpid, u16 seqnum, int last);
int dpaa2_io_service_orp_seqnum_drop(struct dpaa2_io *d, u16 orpid,
u16 seqnum);
int dpaa2_io_query_fq_count(struct dpaa2_io *d, u32 fqid,
u32 *fcnt, u32 *bcnt);
int dpaa2_io_query_bp_count(struct dpaa2_io *d, u16 bpid,