1 From bec2af878c58bbd12f9009948d4fc58ad9c7c1d3 Mon Sep 17 00:00:00 2001
2 From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
3 Date: Fri, 5 May 2017 18:45:50 +0300
4 Subject: [PATCH] dpaa2-eth: Add Tx shaping API
6 DPNIs can be configured to accept a maximum Tx rate and
7 burst size. Add the MC API for controlling these parameters.
9 Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
11 drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h | 8 +++++++
12 drivers/net/ethernet/freescale/dpaa2/dpni.c | 29 +++++++++++++++++++++++++
13 drivers/net/ethernet/freescale/dpaa2/dpni.h | 15 +++++++++++++
14 3 files changed, 52 insertions(+)
16 --- a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
17 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
18 @@ -315,6 +315,14 @@ struct dpni_rsp_get_link_state {
22 +struct dpni_cmd_set_tx_shaping {
24 + __le16 max_burst_size;
30 struct dpni_cmd_set_max_frame_length {
31 __le16 max_frame_length;
33 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.c
34 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.c
35 @@ -926,6 +926,35 @@ int dpni_get_link_state(struct fsl_mc_io
39 + * dpni_set_tx_shaping() - Set the transmit shaping
40 + * @mc_io: Pointer to MC portal's I/O object
41 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
42 + * @token: Token of DPNI object
43 + * @tx_shaper: Tx shaping configuration
45 + * Return: '0' on Success; Error code otherwise.
47 +int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
50 + const struct dpni_tx_shaping_cfg *tx_shaper)
52 + struct fsl_mc_command cmd = { 0 };
53 + struct dpni_cmd_set_tx_shaping *cmd_params;
55 + /* prepare command */
56 + cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_SHAPING,
59 + cmd_params = (struct dpni_cmd_set_tx_shaping *)cmd.params;
60 + cmd_params->max_burst_size = cpu_to_le16(tx_shaper->max_burst_size);
61 + cmd_params->rate_limit = cpu_to_le32(tx_shaper->rate_limit);
63 + /* send command to mc*/
64 + return mc_send_command(mc_io, &cmd);
68 * dpni_set_max_frame_length() - Set the maximum received frame length.
69 * @mc_io: Pointer to MC portal's I/O object
70 * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
71 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.h
72 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.h
73 @@ -555,6 +555,21 @@ int dpni_get_link_state(struct fsl_mc_io
75 struct dpni_link_state *state);
78 + * struct dpni_tx_shaping - Structure representing DPNI tx shaping configuration
79 + * @rate_limit: rate in Mbps
80 + * @max_burst_size: burst size in bytes (up to 64KB)
82 +struct dpni_tx_shaping_cfg {
87 +int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
90 + const struct dpni_tx_shaping_cfg *tx_shaper);
92 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,