Skip to content

Commit 9c20346

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Get switch config, scheduler config and device capabilities
This patch adds to the initialization flow by getting switch configuration, scheduler configuration and device capabilities. Switch configuration: On boot, an L2 switch element is created in the firmware per physical function. Each physical function is also mapped to a port, to which its switch element is connected. In other words, this switch can be visualized as an embedded vSwitch that can connect a physical function's virtual station interfaces (VSIs) to the egress/ingress port. Egress/ingress filters will be eventually created and applied on this switch element. As part of the initialization flow, the driver gets configuration data from this switch element and stores it. Scheduler configuration: The Tx scheduler is a subsystem responsible for setting and enforcing QoS. As part of the initialization flow, the driver queries and stores the default scheduler configuration for the given physical function. Device capabilities: As part of initialization, the driver has to determine what the device is capable of (ex. max queues, VSIs, etc). This information is obtained from the firmware and stored by the driver. CC: Shannon Nelson <[email protected]> Signed-off-by: Anirudh Venkataramanan <[email protected]> Acked-by: Shannon Nelson <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent f31e4b6 commit 9c20346

File tree

10 files changed

+1082
-1
lines changed

10 files changed

+1082
-1
lines changed

drivers/net/ethernet/intel/ice/Makefile

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -10,4 +10,6 @@ obj-$(CONFIG_ICE) += ice.o
1010
ice-y := ice_main.o \
1111
ice_controlq.o \
1212
ice_common.o \
13-
ice_nvm.o
13+
ice_nvm.o \
14+
ice_switch.o \
15+
ice_sched.o

drivers/net/ethernet/intel/ice/ice.h

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -16,7 +16,9 @@
1616
#include <linux/bitmap.h>
1717
#include "ice_devids.h"
1818
#include "ice_type.h"
19+
#include "ice_switch.h"
1920
#include "ice_common.h"
21+
#include "ice_sched.h"
2022

2123
#define ICE_BAR0 0
2224
#define ICE_AQ_LEN 64

drivers/net/ethernet/intel/ice/ice_adminq_cmd.h

Lines changed: 209 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -8,6 +8,8 @@
88
* descriptor format. It is shared between Firmware and Software.
99
*/
1010

11+
#define ICE_AQC_TOPO_MAX_LEVEL_NUM 0x9
12+
1113
struct ice_aqc_generic {
1214
__le32 param0;
1315
__le32 param1;
@@ -68,13 +70,202 @@ struct ice_aqc_req_res {
6870
u8 reserved[2];
6971
};
7072

73+
/* Get function capabilities (indirect 0x000A)
74+
* Get device capabilities (indirect 0x000B)
75+
*/
76+
struct ice_aqc_list_caps {
77+
u8 cmd_flags;
78+
u8 pf_index;
79+
u8 reserved[2];
80+
__le32 count;
81+
__le32 addr_high;
82+
__le32 addr_low;
83+
};
84+
85+
/* Device/Function buffer entry, repeated per reported capability */
86+
struct ice_aqc_list_caps_elem {
87+
__le16 cap;
88+
#define ICE_AQC_CAPS_VSI 0x0017
89+
#define ICE_AQC_CAPS_RSS 0x0040
90+
#define ICE_AQC_CAPS_RXQS 0x0041
91+
#define ICE_AQC_CAPS_TXQS 0x0042
92+
#define ICE_AQC_CAPS_MSIX 0x0043
93+
#define ICE_AQC_CAPS_MAX_MTU 0x0047
94+
95+
u8 major_ver;
96+
u8 minor_ver;
97+
/* Number of resources described by this capability */
98+
__le32 number;
99+
/* Only meaningful for some types of resources */
100+
__le32 logical_id;
101+
/* Only meaningful for some types of resources */
102+
__le32 phys_id;
103+
__le64 rsvd1;
104+
__le64 rsvd2;
105+
};
106+
71107
/* Clear PXE Command and response (direct 0x0110) */
72108
struct ice_aqc_clear_pxe {
73109
u8 rx_cnt;
74110
#define ICE_AQC_CLEAR_PXE_RX_CNT 0x2
75111
u8 reserved[15];
76112
};
77113

114+
/* Get switch configuration (0x0200) */
115+
struct ice_aqc_get_sw_cfg {
116+
/* Reserved for command and copy of request flags for response */
117+
__le16 flags;
118+
/* First desc in case of command and next_elem in case of response
119+
* In case of response, if it is not zero, means all the configuration
120+
* was not returned and new command shall be sent with this value in
121+
* the 'first desc' field
122+
*/
123+
__le16 element;
124+
/* Reserved for command, only used for response */
125+
__le16 num_elems;
126+
__le16 rsvd;
127+
__le32 addr_high;
128+
__le32 addr_low;
129+
};
130+
131+
/* Each entry in the response buffer is of the following type: */
132+
struct ice_aqc_get_sw_cfg_resp_elem {
133+
/* VSI/Port Number */
134+
__le16 vsi_port_num;
135+
#define ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_S 0
136+
#define ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_M \
137+
(0x3FF << ICE_AQC_GET_SW_CONF_RESP_VSI_PORT_NUM_S)
138+
#define ICE_AQC_GET_SW_CONF_RESP_TYPE_S 14
139+
#define ICE_AQC_GET_SW_CONF_RESP_TYPE_M (0x3 << ICE_AQC_GET_SW_CONF_RESP_TYPE_S)
140+
#define ICE_AQC_GET_SW_CONF_RESP_PHYS_PORT 0
141+
#define ICE_AQC_GET_SW_CONF_RESP_VIRT_PORT 1
142+
#define ICE_AQC_GET_SW_CONF_RESP_VSI 2
143+
144+
/* SWID VSI/Port belongs to */
145+
__le16 swid;
146+
147+
/* Bit 14..0 : PF/VF number VSI belongs to
148+
* Bit 15 : VF indication bit
149+
*/
150+
__le16 pf_vf_num;
151+
#define ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_S 0
152+
#define ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_M \
153+
(0x7FFF << ICE_AQC_GET_SW_CONF_RESP_FUNC_NUM_S)
154+
#define ICE_AQC_GET_SW_CONF_RESP_IS_VF BIT(15)
155+
};
156+
157+
/* The response buffer is as follows. Note that the length of the
158+
* elements array varies with the length of the command response.
159+
*/
160+
struct ice_aqc_get_sw_cfg_resp {
161+
struct ice_aqc_get_sw_cfg_resp_elem elements[1];
162+
};
163+
164+
/* Add TSE (indirect 0x0401)
165+
* Delete TSE (indirect 0x040F)
166+
* Move TSE (indirect 0x0408)
167+
*/
168+
struct ice_aqc_add_move_delete_elem {
169+
__le16 num_grps_req;
170+
__le16 num_grps_updated;
171+
__le32 reserved;
172+
__le32 addr_high;
173+
__le32 addr_low;
174+
};
175+
176+
struct ice_aqc_elem_info_bw {
177+
__le16 bw_profile_idx;
178+
__le16 bw_alloc;
179+
};
180+
181+
struct ice_aqc_txsched_elem {
182+
u8 elem_type; /* Special field, reserved for some aq calls */
183+
#define ICE_AQC_ELEM_TYPE_UNDEFINED 0x0
184+
#define ICE_AQC_ELEM_TYPE_ROOT_PORT 0x1
185+
#define ICE_AQC_ELEM_TYPE_TC 0x2
186+
#define ICE_AQC_ELEM_TYPE_SE_GENERIC 0x3
187+
#define ICE_AQC_ELEM_TYPE_ENTRY_POINT 0x4
188+
#define ICE_AQC_ELEM_TYPE_LEAF 0x5
189+
#define ICE_AQC_ELEM_TYPE_SE_PADDED 0x6
190+
u8 valid_sections;
191+
#define ICE_AQC_ELEM_VALID_GENERIC BIT(0)
192+
#define ICE_AQC_ELEM_VALID_CIR BIT(1)
193+
#define ICE_AQC_ELEM_VALID_EIR BIT(2)
194+
#define ICE_AQC_ELEM_VALID_SHARED BIT(3)
195+
u8 generic;
196+
#define ICE_AQC_ELEM_GENERIC_MODE_M 0x1
197+
#define ICE_AQC_ELEM_GENERIC_PRIO_S 0x1
198+
#define ICE_AQC_ELEM_GENERIC_PRIO_M (0x7 << ICE_AQC_ELEM_GENERIC_PRIO_S)
199+
#define ICE_AQC_ELEM_GENERIC_SP_S 0x4
200+
#define ICE_AQC_ELEM_GENERIC_SP_M (0x1 << ICE_AQC_ELEM_GENERIC_SP_S)
201+
#define ICE_AQC_ELEM_GENERIC_ADJUST_VAL_S 0x5
202+
#define ICE_AQC_ELEM_GENERIC_ADJUST_VAL_M \
203+
(0x3 << ICE_AQC_ELEM_GENERIC_ADJUST_VAL_S)
204+
u8 flags; /* Special field, reserved for some aq calls */
205+
#define ICE_AQC_ELEM_FLAG_SUSPEND_M 0x1
206+
struct ice_aqc_elem_info_bw cir_bw;
207+
struct ice_aqc_elem_info_bw eir_bw;
208+
__le16 srl_id;
209+
__le16 reserved2;
210+
};
211+
212+
struct ice_aqc_txsched_elem_data {
213+
__le32 parent_teid;
214+
__le32 node_teid;
215+
struct ice_aqc_txsched_elem data;
216+
};
217+
218+
struct ice_aqc_txsched_topo_grp_info_hdr {
219+
__le32 parent_teid;
220+
__le16 num_elems;
221+
__le16 reserved2;
222+
};
223+
224+
struct ice_aqc_delete_elem {
225+
struct ice_aqc_txsched_topo_grp_info_hdr hdr;
226+
__le32 teid[1];
227+
};
228+
229+
/* Query Scheduler Resource Allocation (indirect 0x0412)
230+
* This indirect command retrieves the scheduler resources allocated by
231+
* EMP Firmware to the given PF.
232+
*/
233+
struct ice_aqc_query_txsched_res {
234+
u8 reserved[8];
235+
__le32 addr_high;
236+
__le32 addr_low;
237+
};
238+
239+
struct ice_aqc_generic_sched_props {
240+
__le16 phys_levels;
241+
__le16 logical_levels;
242+
u8 flattening_bitmap;
243+
u8 max_device_cgds;
244+
u8 max_pf_cgds;
245+
u8 rsvd0;
246+
__le16 rdma_qsets;
247+
u8 rsvd1[22];
248+
};
249+
250+
struct ice_aqc_layer_props {
251+
u8 logical_layer;
252+
u8 chunk_size;
253+
__le16 max_device_nodes;
254+
__le16 max_pf_nodes;
255+
u8 rsvd0[2];
256+
__le16 max_shared_rate_lmtr;
257+
__le16 max_children;
258+
__le16 max_cir_rl_profiles;
259+
__le16 max_eir_rl_profiles;
260+
__le16 max_srl_profiles;
261+
u8 rsvd1[14];
262+
};
263+
264+
struct ice_aqc_query_txsched_res_resp {
265+
struct ice_aqc_generic_sched_props sched_props;
266+
struct ice_aqc_layer_props layer_props[ICE_AQC_TOPO_MAX_LEVEL_NUM];
267+
};
268+
78269
/* NVM Read command (indirect 0x0701)
79270
* NVM Erase commands (direct 0x0702)
80271
* NVM Update commands (indirect 0x0703)
@@ -128,6 +319,10 @@ struct ice_aq_desc {
128319
struct ice_aqc_q_shutdown q_shutdown;
129320
struct ice_aqc_req_res res_owner;
130321
struct ice_aqc_clear_pxe clear_pxe;
322+
struct ice_aqc_list_caps get_cap;
323+
struct ice_aqc_get_sw_cfg get_sw_conf;
324+
struct ice_aqc_query_txsched_res query_sched_res;
325+
struct ice_aqc_add_move_delete_elem add_move_delete_elem;
131326
struct ice_aqc_nvm nvm;
132327
} params;
133328
};
@@ -136,16 +331,19 @@ struct ice_aq_desc {
136331
#define ICE_AQ_LG_BUF 512
137332

138333
#define ICE_AQ_FLAG_LB_S 9
334+
#define ICE_AQ_FLAG_RD_S 10
139335
#define ICE_AQ_FLAG_BUF_S 12
140336
#define ICE_AQ_FLAG_SI_S 13
141337

142338
#define ICE_AQ_FLAG_LB BIT(ICE_AQ_FLAG_LB_S) /* 0x200 */
339+
#define ICE_AQ_FLAG_RD BIT(ICE_AQ_FLAG_RD_S) /* 0x400 */
143340
#define ICE_AQ_FLAG_BUF BIT(ICE_AQ_FLAG_BUF_S) /* 0x1000 */
144341
#define ICE_AQ_FLAG_SI BIT(ICE_AQ_FLAG_SI_S) /* 0x2000 */
145342

146343
/* error codes */
147344
enum ice_aq_err {
148345
ICE_AQ_RC_OK = 0, /* success */
346+
ICE_AQ_RC_ENOMEM = 9, /* Out of memory */
149347
ICE_AQ_RC_EBUSY = 12, /* Device or resource busy */
150348
ICE_AQ_RC_EEXIST = 13, /* object already exists */
151349
};
@@ -160,11 +358,22 @@ enum ice_adminq_opc {
160358
ice_aqc_opc_req_res = 0x0008,
161359
ice_aqc_opc_release_res = 0x0009,
162360

361+
/* device/function capabilities */
362+
ice_aqc_opc_list_func_caps = 0x000A,
363+
ice_aqc_opc_list_dev_caps = 0x000B,
364+
163365
/* PXE */
164366
ice_aqc_opc_clear_pxe_mode = 0x0110,
165367

368+
/* internal switch commands */
369+
ice_aqc_opc_get_sw_cfg = 0x0200,
370+
166371
ice_aqc_opc_clear_pf_cfg = 0x02A4,
167372

373+
/* transmit scheduler commands */
374+
ice_aqc_opc_delete_sched_elems = 0x040F,
375+
ice_aqc_opc_query_sched_res = 0x0412,
376+
168377
/* NVM commands */
169378
ice_aqc_opc_nvm_read = 0x0701,
170379

0 commit comments

Comments
 (0)