blob: f1bbc5546d751eb97586b17cf05bafd601c989e5 [file] [log] [blame]
b.liue9582032025-04-17 19:18:16 +08001From bec2af878c58bbd12f9009948d4fc58ad9c7c1d3 Mon Sep 17 00:00:00 2001
2From: Ioana Radulescu <ruxandra.radulescu@nxp.com>
3Date: Fri, 5 May 2017 18:45:50 +0300
4Subject: [PATCH] dpaa2-eth: Add Tx shaping API
5
6DPNIs can be configured to accept a maximum Tx rate and
7burst size. Add the MC API for controlling these parameters.
8
9Signed-off-by: Ioana Radulescu <ruxandra.radulescu@nxp.com>
10---
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(+)
15
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 {
19 __le64 options;
20 };
21
22+struct dpni_cmd_set_tx_shaping {
23+ /* cmd word 0 */
24+ __le16 max_burst_size;
25+ __le16 pad[3];
26+ /* cmd word 1 */
27+ __le32 rate_limit;
28+};
29+
30 struct dpni_cmd_set_max_frame_length {
31 __le16 max_frame_length;
32 };
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
36 }
37
38 /**
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
44+ *
45+ * Return: '0' on Success; Error code otherwise.
46+ */
47+int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
48+ u32 cmd_flags,
49+ u16 token,
50+ const struct dpni_tx_shaping_cfg *tx_shaper)
51+{
52+ struct fsl_mc_command cmd = { 0 };
53+ struct dpni_cmd_set_tx_shaping *cmd_params;
54+
55+ /* prepare command */
56+ cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_SHAPING,
57+ cmd_flags,
58+ token);
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);
62+
63+ /* send command to mc*/
64+ return mc_send_command(mc_io, &cmd);
65+}
66+
67+/**
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
74 u16 token,
75 struct dpni_link_state *state);
76
77+/**
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)
81+ */
82+struct dpni_tx_shaping_cfg {
83+ u32 rate_limit;
84+ u16 max_burst_size;
85+};
86+
87+int dpni_set_tx_shaping(struct fsl_mc_io *mc_io,
88+ u32 cmd_flags,
89+ u16 token,
90+ const struct dpni_tx_shaping_cfg *tx_shaper);
91+
92 int dpni_set_max_frame_length(struct fsl_mc_io *mc_io,
93 u32 cmd_flags,
94 u16 token,