23deef656782e8c3f0b76037c5dbdf04599922d0
[openwrt/staging/blocktrron.git] /
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
5
6 Support dual rate shaping (committed, excess) and the coupled parameter.
7
8 Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
9 ---
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(-)
15
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
19 {
20 int err, items;
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};
24
25 items = sscanf(buf, "%u %hu", &scfg.rate_limit, &scfg.max_burst_size);
26 if (items != 2) {
27 @@ -3902,7 +3902,8 @@ static ssize_t dpaa2_eth_write_tx_shapin
28 return -EINVAL;
29 }
30
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,
33 + &ercfg, 0);
34 if (err) {
35 dev_err(dev, "dpni_set_tx_shaping() failed\n");
36 return -EPERM;
37 --- a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
38 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
39 @@ -11,9 +11,11 @@
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
45
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)
48
49 #define DPNI_CMDID_OPEN DPNI_CMD(0x801)
50 #define DPNI_CMDID_CLOSE DPNI_CMD(0x800)
51 @@ -45,7 +47,7 @@
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)
57
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 {
61 __le64 options;
62 };
63
64 +#define DPNI_COUPLED_SHIFT 0
65 +#define DPNI_COUPLED_SIZE 1
66 +
67 struct dpni_cmd_set_tx_shaping {
68 /* cmd word 0 */
69 - __le16 max_burst_size;
70 - __le16 pad[3];
71 + __le16 tx_cr_max_burst_size;
72 + __le16 tx_er_max_burst_size;
73 + __le32 pad;
74 /* cmd word 1 */
75 - __le32 rate_limit;
76 + __le32 tx_cr_rate_limit;
77 + __le32 tx_er_rate_limit;
78 + /* cmd word 2 */
79 + /* from LSB: coupled:1 */
80 + u8 coupled;
81 };
82
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
87
88 /**
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
100 *
101 * Return: '0' on Success; Error code otherwise.
102 */
103 int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
104 u32 cmd_flags,
105 u16 token,
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,
109 + int coupled)
110 {
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
114 cmd_flags,
115 token);
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);
126
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 {
132 u16 max_burst_size;
133 };
134
135 -int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
136 - u32 cmd_flags,
137 - u16 token,
138 - const struct dpni_tx_shaping_cfg *tx_shaper);
139 +int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
140 + u32 cmd_flags,
141 + u16 token,
142 + const struct dpni_tx_shaping_cfg *tx_cr_shaper,
143 + const struct dpni_tx_shaping_cfg *tx_er_shaper,
144 + int coupled);
145
146 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
147 u32 cmd_flags,