1 From 81efe5fd6fac6db454ccccb1e6c280419d0885c4 Mon Sep 17 00:00:00 2001
2 From: Bogdan Purcareata <bogdan.purcareata@nxp.com>
3 Date: Mon, 13 Nov 2017 17:29:21 +0200
4 Subject: [PATCH] dpaa2-eth: Update dpni_set_tx_shaping cmd to v2
6 Support dual rate shaping (committed, excess) and the coupled parameter.
8 Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
10 drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c | 5 +++--
11 drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h | 18 ++++++++++++++----
12 drivers/net/ethernet/freescale/dpaa2/dpni.c | 23 ++++++++++++++++-------
13 drivers/net/ethernet/freescale/dpaa2/dpni.h | 10 ++++++----
14 4 files changed, 39 insertions(+), 17 deletions(-)
16 --- a/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
17 +++ b/drivers/net/ethernet/freescale/dpaa2/dpaa2-eth.c
18 @@ -3888,7 +3888,7 @@ static ssize_t dpaa2_eth_write_tx_shapin
21 struct dpaa2_eth_priv *priv = netdev_priv(to_net_dev(dev));
22 - struct dpni_tx_shaping_cfg scfg;
23 + struct dpni_tx_shaping_cfg scfg, ercfg = {0};
25 items = sscanf(buf, "%u %hu", &scfg.rate_limit, &scfg.max_burst_size);
27 @@ -3902,7 +3902,8 @@ static ssize_t dpaa2_eth_write_tx_shapin
31 - err = dpni_set_tx_shaping(priv->mc_io, 0, priv->mc_token, &scfg);
32 + err = dpni_set_tx_shaping(priv->mc_io, 0, priv->mc_token, &scfg,
35 dev_err(dev, "dpni_set_tx_shaping() failed\n");
37 --- a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
38 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
40 #define DPNI_VER_MAJOR 7
41 #define DPNI_VER_MINOR 0
42 #define DPNI_CMD_BASE_VERSION 1
43 +#define DPNI_CMD_2ND_VERSION 2
44 #define DPNI_CMD_ID_OFFSET 4
46 #define DPNI_CMD(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_BASE_VERSION)
47 +#define DPNI_CMD_V2(id) (((id) << DPNI_CMD_ID_OFFSET) | DPNI_CMD_2ND_VERSION)
49 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
50 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
52 #define DPNI_CMDID_SET_MAX_FRAME_LENGTH DPNI_CMD(0x216)
53 #define DPNI_CMDID_GET_MAX_FRAME_LENGTH DPNI_CMD(0x217)
54 #define DPNI_CMDID_SET_LINK_CFG DPNI_CMD(0x21A)
55 -#define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD(0x21B)
56 +#define DPNI_CMDID_SET_TX_SHAPING DPNI_CMD_V2(0x21B)
58 #define DPNI_CMDID_SET_MCAST_PROMISC DPNI_CMD(0x220)
59 #define DPNI_CMDID_GET_MCAST_PROMISC DPNI_CMD(0x221)
60 @@ -316,12 +318,20 @@ struct dpni_rsp_get_link_state {
64 +#define DPNI_COUPLED_SHIFT 0
65 +#define DPNI_COUPLED_SIZE 1
67 struct dpni_cmd_set_tx_shaping {
69 - __le16 max_burst_size;
71 + __le16 tx_cr_max_burst_size;
72 + __le16 tx_er_max_burst_size;
76 + __le32 tx_cr_rate_limit;
77 + __le32 tx_er_rate_limit;
79 + /* from LSB: coupled:1 */
83 struct dpni_cmd_set_max_frame_length {
84 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.c
85 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.c
86 @@ -927,17 +927,21 @@ int dpni_get_link_state(struct fsl_mc_io
89 * dpni_set_tx_shaping() - Set the transmit shaping
90 - * @mc_io: Pointer to MC portal's I/O object
91 - * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
92 - * @token: Token of DPNI object
93 - * @tx_shaper: Tx shaping configuration
94 + * @mc_io: Pointer to MC portal's I/O object
95 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
96 + * @token: Token of DPNI object
97 + * @tx_cr_shaper: TX committed rate shaping configuration
98 + * @tx_er_shaper: TX excess rate shaping configuration
99 + * @coupled: Committed and excess rate shapers are coupled
101 * Return: '0' on Success; Error code otherwise.
103 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
106 - const struct dpni_tx_shaping_cfg *tx_shaper)
107 + const struct dpni_tx_shaping_cfg *tx_cr_shaper,
108 + const struct dpni_tx_shaping_cfg *tx_er_shaper,
111 struct fsl_mc_command cmd = { 0 };
112 struct dpni_cmd_set_tx_shaping *cmd_params;
113 @@ -947,8 +951,13 @@ int dpni_set_tx_shaping(struct fsl_mc_io
116 cmd_params = (struct dpni_cmd_set_tx_shaping *)cmd.params;
117 - cmd_params->max_burst_size = cpu_to_le16(tx_shaper->max_burst_size);
118 - cmd_params->rate_limit = cpu_to_le32(tx_shaper->rate_limit);
119 + cmd_params->tx_cr_max_burst_size =
120 + cpu_to_le16(tx_cr_shaper->max_burst_size);
121 + cmd_params->tx_er_max_burst_size =
122 + cpu_to_le16(tx_er_shaper->max_burst_size);
123 + cmd_params->tx_cr_rate_limit = cpu_to_le32(tx_cr_shaper->rate_limit);
124 + cmd_params->tx_er_rate_limit = cpu_to_le32(tx_er_shaper->rate_limit);
125 + dpni_set_field(cmd_params->coupled, COUPLED, coupled);
127 /* send command to mc*/
128 return mc_send_command(mc_io, &cmd);
129 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.h
130 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.h
131 @@ -569,10 +569,12 @@ struct dpni_tx_shaping_cfg {
135 -int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
138 - const struct dpni_tx_shaping_cfg *tx_shaper);
139 +int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
142 + const struct dpni_tx_shaping_cfg *tx_cr_shaper,
143 + const struct dpni_tx_shaping_cfg *tx_er_shaper,
146 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,