net/dpaa2: add support for tail drop on queue

This will help in limiting the size of queues and avoid
them growing practically infinite.

Signed-off-by: Hemant Agrawal <hemant.agrawal@nxp.com>
This commit is contained in:
Hemant Agrawal 2017-05-26 12:21:14 +05:30 committed by Ferruh Yigit
parent 7ae777d064
commit 23d6a87ee2
5 changed files with 191 additions and 0 deletions

View File

@ -309,6 +309,25 @@ dpaa2_dev_rx_queue_setup(struct rte_eth_dev *dev,
return -1;
}
if (!(priv->flags & DPAA2_RX_TAILDROP_OFF)) {
struct dpni_taildrop taildrop;
taildrop.enable = 1;
/*enabling per rx queue congestion control */
taildrop.threshold = CONG_THRESHOLD_RX_Q;
taildrop.units = DPNI_CONGESTION_UNIT_BYTES;
PMD_INIT_LOG(DEBUG, "Enabling Early Drop on queue = %d",
rx_queue_id);
ret = dpni_set_taildrop(dpni, CMD_PRI_LOW, priv->token,
DPNI_CP_QUEUE, DPNI_QUEUE_RX,
dpaa2_q->tc_index, flow_id, &taildrop);
if (ret) {
PMD_INIT_LOG(ERR, "Error in setting the rx flow"
" err : = %d\n", ret);
return -1;
}
}
dev->data->rx_queues[rx_queue_id] = dpaa2_q;
return 0;
}

View File

@ -56,6 +56,11 @@
*/
#define CONG_EXIT_TX_THRESHOLD (24 * 1024)
/* RX queue tail drop threshold
* currently considering 32 KB packets
*/
#define CONG_THRESHOLD_RX_Q (32 * 1024)
/* Size of the input SMMU mapped memory required by MC */
#define DIST_PARAM_IOVA_SIZE 256
@ -64,6 +69,9 @@
*/
#define DPAA2_TX_CGR_SUPPORT 0x01
/* Disable RX tail drop, default is enable */
#define DPAA2_RX_TAILDROP_OFF 0x04
struct dpaa2_dev_priv {
void *hw;
int32_t hw_id;

View File

@ -785,3 +785,53 @@ int dpni_reset_statistics(struct fsl_mc_io *mc_io,
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
int dpni_set_taildrop(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
enum dpni_congestion_point cg_point,
enum dpni_queue_type q_type,
uint8_t tc,
uint8_t q_index,
struct dpni_taildrop *taildrop)
{
struct mc_command cmd = { 0 };
/* prepare command */
cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TAILDROP,
cmd_flags,
token);
DPNI_CMD_SET_TAILDROP(cmd, cg_point, q_type, tc, q_index, taildrop);
/* send command to mc*/
return mc_send_command(mc_io, &cmd);
}
int dpni_get_taildrop(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
enum dpni_congestion_point cg_point,
enum dpni_queue_type q_type,
uint8_t tc,
uint8_t q_index,
struct dpni_taildrop *taildrop)
{
struct mc_command cmd = { 0 };
int err;
/* prepare command */
cmd.header = mc_encode_cmd_header(DPNI_CMDID_GET_TAILDROP,
cmd_flags,
token);
DPNI_CMD_GET_TAILDROP(cmd, cg_point, q_type, tc, q_index);
/* send command to mc*/
err = mc_send_command(mc_io, &cmd);
if (err)
return err;
/* retrieve response parameters */
DPNI_RSP_GET_TAILDROP(cmd, taildrop);
return 0;
}

View File

@ -1336,4 +1336,89 @@ int dpni_reset_statistics(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token);
/**
* enum dpni_congestion_point - Structure representing congestion point
* @DPNI_CP_QUEUE: Set taildrop per queue, identified by QUEUE_TYPE, TC and
* QUEUE_INDEX
* @DPNI_CP_GROUP: Set taildrop per queue group. Depending on options used
* to define the DPNI this can be either per
* TC (default) or per interface
* (DPNI_OPT_SHARED_CONGESTION set at DPNI create).
* QUEUE_INDEX is ignored if this type is used.
*/
enum dpni_congestion_point {
DPNI_CP_QUEUE,
DPNI_CP_GROUP,
};
/**
* struct dpni_taildrop - Structure representing the taildrop
* @enable: Indicates whether the taildrop is active or not.
* @units: Indicates the unit of THRESHOLD. Queue taildrop only
* supports byte units, this field is ignored and
* assumed = 0 if CONGESTION_POINT is 0.
* @threshold: Threshold value, in units identified by UNITS field. Value 0
* cannot be used as a valid taildrop threshold,
* THRESHOLD must be > 0 if the taildrop is
* enabled.
*/
struct dpni_taildrop {
char enable;
enum dpni_congestion_unit units;
uint32_t threshold;
};
/**
* dpni_set_taildrop() - Set taildrop per queue or TC
*
* Setting a per-TC taildrop (cg_point = DPNI_CP_GROUP) will reset any current
* congestion notification or early drop (WRED) configuration previously applied
* to the same TC.
*
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPNI object
* @cg_point: Congestion point. DPNI_CP_QUEUE is only supported in
* combination with DPNI_QUEUE_RX.
* @q_type: Queue type, can be DPNI_QUEUE_RX or DPNI_QUEUE_TX.
* @tc: Traffic class to apply this taildrop to
* @q_index: Index of the queue if the DPNI supports multiple queues for
* traffic distribution.
* Ignored if CONGESTION_POINT is not DPNI_CP_QUEUE.
* @taildrop: Taildrop structure
*
* Return: '0' on Success; Error code otherwise.
*/
int dpni_set_taildrop(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
enum dpni_congestion_point cg_point,
enum dpni_queue_type q_type,
uint8_t tc,
uint8_t q_index,
struct dpni_taildrop *taildrop);
/**
* dpni_get_taildrop() - Get taildrop information
* @mc_io: Pointer to MC portal's I/O object
* @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
* @token: Token of DPNI object
* @cg_point: Congestion point
* @q_type:
* @tc: Traffic class to apply this taildrop to
* @q_index: Index of the queue if the DPNI supports multiple queues for
* traffic distribution. Ignored if CONGESTION_POINT
* is not 0.
* @taildrop: Taildrop structure
*
* Return: '0' on Success; Error code otherwise.
*/
int dpni_get_taildrop(struct fsl_mc_io *mc_io,
uint32_t cmd_flags,
uint16_t token,
enum dpni_congestion_point cg_point,
enum dpni_queue_type q_type,
uint8_t tc,
uint8_t q_index,
struct dpni_taildrop *taildrop);
#endif /* __FSL_DPNI_H */

View File

@ -76,6 +76,8 @@
#define DPNI_CMDID_RESET_STATISTICS ((0x25E << 4) | (0x1))
#define DPNI_CMDID_GET_QUEUE ((0x25F << 4) | (0x1))
#define DPNI_CMDID_SET_QUEUE ((0x260 << 4) | (0x1))
#define DPNI_CMDID_GET_TAILDROP ((0x261 << 4) | (0x1))
#define DPNI_CMDID_SET_TAILDROP ((0x262 << 4) | (0x1))
#define DPNI_CMDID_GET_PORT_MAC_ADDR ((0x263 << 4) | (0x1))
@ -326,6 +328,33 @@ do { \
MC_RSP_OP(cmd, 0, 16, 16, uint16_t, minor);\
} while (0)
#define DPNI_CMD_GET_TAILDROP(cmd, cp, q_type, tc, q_index) \
do { \
MC_CMD_OP(cmd, 0, 0, 8, enum dpni_congestion_point, cp); \
MC_CMD_OP(cmd, 0, 8, 8, enum dpni_queue_type, q_type); \
MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc); \
MC_CMD_OP(cmd, 0, 24, 8, uint8_t, q_index); \
} while (0)
#define DPNI_RSP_GET_TAILDROP(cmd, taildrop) \
do { \
MC_RSP_OP(cmd, 1, 0, 1, char, (taildrop)->enable); \
MC_RSP_OP(cmd, 1, 16, 8, enum dpni_congestion_unit, \
(taildrop)->units); \
MC_RSP_OP(cmd, 1, 32, 32, uint32_t, (taildrop)->threshold); \
} while (0)
#define DPNI_CMD_SET_TAILDROP(cmd, cp, q_type, tc, q_index, taildrop) \
do { \
MC_CMD_OP(cmd, 0, 0, 8, enum dpni_congestion_point, cp); \
MC_CMD_OP(cmd, 0, 8, 8, enum dpni_queue_type, q_type); \
MC_CMD_OP(cmd, 0, 16, 8, uint8_t, tc); \
MC_CMD_OP(cmd, 0, 24, 8, uint8_t, q_index); \
MC_CMD_OP(cmd, 1, 0, 1, char, (taildrop)->enable); \
MC_CMD_OP(cmd, 1, 16, 8, enum dpni_congestion_unit, \
(taildrop)->units); \
MC_CMD_OP(cmd, 1, 32, 32, uint32_t, (taildrop)->threshold); \
} while (0)
#define DPNI_CMD_SET_TX_CONFIRMATION_MODE(cmd, mode) \
MC_CMD_OP(cmd, 0, 32, 8, enum dpni_confirmation_mode, mode)