ath79/mikrotik: use routerbootpart partitions
[oweals/openwrt.git] / target / linux / layerscape / patches-5.4 / 701-net-0210-dpaa2-eth-Add-dpni_set_tx_priorities-API.patch
1 From 97308e74e2ae781d37437137686965395b94327b Mon Sep 17 00:00:00 2001
2 From: Bogdan Purcareata <bogdan.purcareata@nxp.com>
3 Date: Mon, 16 Oct 2017 15:27:55 +0000
4 Subject: [PATCH] dpaa2-eth: Add dpni_set_tx_priorities API
5
6 Signed-off-by: Bogdan Purcareata <bogdan.purcareata@nxp.com>
7 ---
8  drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h | 19 ++++++++++
9  drivers/net/ethernet/freescale/dpaa2/dpni.c     | 49 +++++++++++++++++++++++++
10  drivers/net/ethernet/freescale/dpaa2/dpni.h     | 44 ++++++++++++++++++++++
11  3 files changed, 112 insertions(+)
12
13 --- a/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
14 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni-cmd.h
15 @@ -69,6 +69,7 @@
16  #define DPNI_CMDID_REMOVE_FS_ENT                       DPNI_CMD(0x245)
17  #define DPNI_CMDID_CLR_FS_ENT                          DPNI_CMD(0x246)
18  
19 +#define DPNI_CMDID_SET_TX_PRIORITIES                   DPNI_CMD_V2(0x250)
20  #define DPNI_CMDID_GET_STATISTICS                      DPNI_CMD(0x25D)
21  #define DPNI_CMDID_RESET_STATISTICS                    DPNI_CMD(0x25E)
22  #define DPNI_CMDID_GET_QUEUE                           DPNI_CMD(0x25F)
23 @@ -393,6 +394,24 @@ struct dpni_cmd_clear_mac_filters {
24         u8 flags;
25  };
26  
27 +#define DPNI_SEPARATE_GRP_SHIFT 0
28 +#define DPNI_SEPARATE_GRP_SIZE  1
29 +#define DPNI_MODE_1_SHIFT              0
30 +#define DPNI_MODE_1_SIZE               4
31 +#define DPNI_MODE_2_SHIFT              4
32 +#define DPNI_MODE_2_SIZE               4
33 +
34 +struct dpni_cmd_set_tx_priorities {
35 +       __le16 flags;
36 +       u8 prio_group_A;
37 +       u8 prio_group_B;
38 +       __le32 pad0;
39 +       u8 modes[4];
40 +       __le32 pad1;
41 +       __le64 pad2;
42 +       __le16 delta_bandwidth[8];
43 +};
44 +
45  #define DPNI_DIST_MODE_SHIFT           0
46  #define DPNI_DIST_MODE_SIZE            4
47  #define DPNI_MISS_ACTION_SHIFT         4
48 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.c
49 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.c
50 @@ -1355,6 +1355,55 @@ int dpni_clear_mac_filters(struct fsl_mc
51  }
52  
53  /**
54 + * dpni_set_tx_priorities() - Set transmission TC priority configuration
55 + * @mc_io:     Pointer to MC portal's I/O object
56 + * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
57 + * @token:     Token of DPNI object
58 + * @cfg:       Transmission selection configuration
59 + *
60 + * warning:    Allowed only when DPNI is disabled
61 + *
62 + * Return:     '0' on Success; Error code otherwise.
63 + */
64 +int dpni_set_tx_priorities(struct fsl_mc_io *mc_io,
65 +                          u32 cmd_flags,
66 +                          u16 token,
67 +                          const struct dpni_tx_priorities_cfg *cfg)
68 +{
69 +       struct dpni_cmd_set_tx_priorities *cmd_params;
70 +       struct fsl_mc_command cmd = { 0 };
71 +       int i;
72 +
73 +       /* prepare command */
74 +       cmd.header = mc_encode_cmd_header(DPNI_CMDID_SET_TX_PRIORITIES,
75 +                                         cmd_flags,
76 +                                         token);
77 +       cmd_params = (struct dpni_cmd_set_tx_priorities *)cmd.params;
78 +       dpni_set_field(cmd_params->flags,
79 +                      SEPARATE_GRP,
80 +                      cfg->separate_groups);
81 +       cmd_params->prio_group_A = cfg->prio_group_A;
82 +       cmd_params->prio_group_B = cfg->prio_group_B;
83 +
84 +       for (i = 0; i + 1 < DPNI_MAX_TC; i += 2) {
85 +               dpni_set_field(cmd_params->modes[i / 2],
86 +                              MODE_1,
87 +                              cfg->tc_sched[i].mode);
88 +               dpni_set_field(cmd_params->modes[i / 2],
89 +                              MODE_2,
90 +                              cfg->tc_sched[i + 1].mode);
91 +       }
92 +
93 +       for (i = 0; i < DPNI_MAX_TC; i++) {
94 +               cmd_params->delta_bandwidth[i] =
95 +                               cpu_to_le16(cfg->tc_sched[i].delta_bandwidth);
96 +       }
97 +
98 +       /* send command to mc*/
99 +       return mc_send_command(mc_io, &cmd);
100 +}
101 +
102 +/**
103   * dpni_set_rx_tc_dist() - Set Rx traffic class distribution configuration
104   * @mc_io:     Pointer to MC portal's I/O object
105   * @cmd_flags: Command flags; one or more of 'MC_CMD_FLAG_'
106 --- a/drivers/net/ethernet/freescale/dpaa2/dpni.h
107 +++ b/drivers/net/ethernet/freescale/dpaa2/dpni.h
108 @@ -677,6 +677,50 @@ int dpni_prepare_key_cfg(const struct dp
109                          u8 *key_cfg_buf);
110  
111  /**
112 + * enum dpni_tx_schedule_mode - DPNI Tx scheduling mode
113 + * @DPNI_TX_SCHED_STRICT_PRIORITY: strict priority
114 + * @DPNI_TX_SCHED_WEIGHTED_A: weighted based scheduling in group A
115 + * @DPNI_TX_SCHED_WEIGHTED_B: weighted based scheduling in group B
116 + */
117 +enum dpni_tx_schedule_mode {
118 +       DPNI_TX_SCHED_STRICT_PRIORITY = 0,
119 +       DPNI_TX_SCHED_WEIGHTED_A,
120 +       DPNI_TX_SCHED_WEIGHTED_B,
121 +};
122 +
123 +/**
124 + * struct dpni_tx_schedule_cfg - Structure representing Tx scheduling conf
125 + * @mode:              Scheduling mode
126 + * @delta_bandwidth:   Bandwidth represented in weights from 100 to 10000;
127 + *     not applicable for 'strict-priority' mode;
128 + */
129 +struct dpni_tx_schedule_cfg {
130 +       enum dpni_tx_schedule_mode mode;
131 +       u16 delta_bandwidth;
132 +};
133 +
134 +/**
135 + * struct dpni_tx_priorities_cfg - Structure representing transmission
136 + *                                     priorities for DPNI TCs
137 + * @tc_sched:  An array of traffic-classes
138 + * @prio_group_A: Priority of group A
139 + * @prio_group_B: Priority of group B
140 + * @separate_groups: Treat A and B groups as separate
141 + * @ceetm_ch_idx: ceetm channel index to apply the changes
142 + */
143 +struct dpni_tx_priorities_cfg {
144 +       struct dpni_tx_schedule_cfg tc_sched[DPNI_MAX_TC];
145 +       u8 prio_group_A;
146 +       u8 prio_group_B;
147 +       u8 separate_groups;
148 +};
149 +
150 +int dpni_set_tx_priorities(struct fsl_mc_io *mc_io,
151 +                          u32 cmd_flags,
152 +                          u16 token,
153 +                          const struct dpni_tx_priorities_cfg *cfg);
154 +
155 +/**
156   * struct dpni_rx_tc_dist_cfg - Rx traffic class distribution configuration
157   * @dist_size: Set the distribution size;
158   *     supported values: 1,2,3,4,6,7,8,12,14,16,24,28,32,48,56,64,96,