Linux kernel mirror (for testing) git.kernel.org/pub/scm/linux/kernel/git/torvalds/linux.git
kernel os linux
1
fork

Configure Feed

Select the types of activity you want to include in your feed.

Merge branch '100GbE' of git://git.kernel.org/pub/scm/linux/kernel/git/jkirsher/next-queue

Jeff Kirsher says:

====================
100GbE Intel Wired LAN Driver Updates 2019-04-18

This series contains updates to the ice driver only.

Anirudh fixes up code comments which had typos. Added support for DCB
into the ice driver, which required a bit of refactoring of the existing
code. Also fixed a potential race condition between closing and opening
the VSI for a MIB change event, so resolved this by grabbing the
rtnl_lock prior to closing. Added support to process LLDP MIB change
notifications. Added support for reporting DCB stats via ethtool.

Brett updates the calculation to increment ITR to use a direct
calculation instead of using estimations. This provides a more accurate
value.
====================

Signed-off-by: David S. Miller <davem@davemloft.net>

+3203 -459
+1
drivers/net/ethernet/intel/ice/Makefile
··· 17 17 ice_txrx.o \ 18 18 ice_ethtool.o 19 19 ice-$(CONFIG_PCI_IOV) += ice_virtchnl_pf.o ice_sriov.o 20 + ice-$(CONFIG_DCB) += ice_dcb.o ice_dcb_lib.o
+18 -12
drivers/net/ethernet/intel/ice/ice.h
··· 34 34 #include "ice_devids.h" 35 35 #include "ice_type.h" 36 36 #include "ice_txrx.h" 37 + #include "ice_dcb.h" 37 38 #include "ice_switch.h" 38 39 #include "ice_common.h" 39 40 #include "ice_sched.h" ··· 152 151 153 152 struct ice_tc_cfg { 154 153 u8 numtc; /* Total number of enabled TCs */ 155 - u8 ena_tc; /* TX map */ 154 + u8 ena_tc; /* Tx map */ 156 155 struct ice_tc_info tc_info[ICE_MAX_TRAFFIC_CLASS]; 157 156 }; 158 157 ··· 163 162 }; 164 163 165 164 struct ice_qs_cfg { 166 - struct mutex *qs_mutex; /* will be assgined to &pf->avail_q_mutex */ 165 + struct mutex *qs_mutex; /* will be assigned to &pf->avail_q_mutex */ 167 166 unsigned long *pf_map; 168 167 unsigned long pf_map_size; 169 168 unsigned int q_count; ··· 322 321 ICE_FLAG_RSS_ENA, 323 322 ICE_FLAG_SRIOV_ENA, 324 323 ICE_FLAG_SRIOV_CAPABLE, 324 + ICE_FLAG_DCB_CAPABLE, 325 + ICE_FLAG_DCB_ENA, 325 326 ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA, 327 + ICE_FLAG_DISABLE_FW_LLDP, 328 + ICE_FLAG_ETHTOOL_CTXT, /* set when ethtool holds RTNL lock */ 326 329 ICE_PF_FLAGS_NBITS /* must be last */ 327 330 }; 328 331 ··· 365 360 u32 hw_oicr_idx; /* Other interrupt cause vector HW index */ 366 361 u32 num_avail_hw_msix; /* remaining HW MSIX vectors left unclaimed */ 367 362 u32 num_lan_msix; /* Total MSIX vectors for base driver */ 368 - u16 num_lan_tx; /* num lan Tx queues setup */ 369 - u16 num_lan_rx; /* num lan Rx queues setup */ 363 + u16 num_lan_tx; /* num LAN Tx queues setup */ 364 + u16 num_lan_rx; /* num LAN Rx queues setup */ 370 365 u16 q_left_tx; /* remaining num Tx queues left unclaimed */ 371 366 u16 q_left_rx; /* remaining num Rx queues left unclaimed */ 372 367 u16 next_vsi; /* Next free slot in pf->vsi[] - 0-based! */ ··· 380 375 struct ice_hw_port_stats stats_prev; 381 376 struct ice_hw hw; 382 377 u8 stat_prev_loaded; /* has previous stats been loaded */ 378 + #ifdef CONFIG_DCB 379 + u16 dcbx_cap; 380 + #endif /* CONFIG_DCB */ 383 381 u32 tx_timeout_count; 384 382 unsigned long tx_timeout_last_recovery; 385 383 u32 tx_timeout_recovery_level; ··· 395 387 396 388 /** 397 389 * ice_irq_dynamic_ena - Enable default interrupt generation settings 398 - * @hw: pointer to hw struct 399 - * @vsi: pointer to vsi struct, can be NULL 390 + * @hw: pointer to HW struct 391 + * @vsi: pointer to VSI struct, can be NULL 400 392 * @q_vector: pointer to q_vector, can be NULL 401 393 */ 402 394 static inline void ··· 419 411 wr32(hw, GLINT_DYN_CTL(vector), val); 420 412 } 421 413 422 - static inline void ice_vsi_set_tc_cfg(struct ice_vsi *vsi) 423 - { 424 - vsi->tc_cfg.ena_tc = ICE_DFLT_TRAFFIC_CLASS; 425 - vsi->tc_cfg.numtc = 1; 426 - } 427 - 428 414 void ice_set_ethtool_ops(struct net_device *netdev); 429 415 int ice_up(struct ice_vsi *vsi); 430 416 int ice_down(struct ice_vsi *vsi); ··· 427 425 void ice_fill_rss_lut(u8 *lut, u16 rss_table_size, u16 rss_size); 428 426 void ice_print_link_msg(struct ice_vsi *vsi, bool isup); 429 427 void ice_napi_del(struct ice_vsi *vsi); 428 + #ifdef CONFIG_DCB 429 + int ice_pf_ena_all_vsi(struct ice_pf *pf, bool locked); 430 + void ice_pf_dis_all_vsi(struct ice_pf *pf, bool locked); 431 + #endif /* CONFIG_DCB */ 430 432 431 433 #endif /* _ICE_H_ */
+174 -10
drivers/net/ethernet/intel/ice/ice_adminq_cmd.h
··· 62 62 #define ICE_AQ_RES_NVM_WRITE_DFLT_TIMEOUT_MS 180000 63 63 #define ICE_AQ_RES_CHNG_LOCK_DFLT_TIMEOUT_MS 1000 64 64 #define ICE_AQ_RES_GLBL_LOCK_DFLT_TIMEOUT_MS 3000 65 - /* For SDP: pin id of the SDP */ 65 + /* For SDP: pin ID of the SDP */ 66 66 __le32 res_number; 67 67 /* Status is only used for ICE_AQC_RES_ID_GLBL_LOCK */ 68 68 __le16 status; ··· 747 747 __le32 teid[1]; 748 748 }; 749 749 750 + /* Query Port ETS (indirect 0x040E) 751 + * 752 + * This indirect command is used to query port TC node configuration. 753 + */ 754 + struct ice_aqc_query_port_ets { 755 + __le32 port_teid; 756 + __le32 reserved; 757 + __le32 addr_high; 758 + __le32 addr_low; 759 + }; 760 + 761 + struct ice_aqc_port_ets_elem { 762 + u8 tc_valid_bits; 763 + u8 reserved[3]; 764 + /* 3 bits for UP per TC 0-7, 4th byte reserved */ 765 + __le32 up2tc; 766 + u8 tc_bw_share[8]; 767 + __le32 port_eir_prof_id; 768 + __le32 port_cir_prof_id; 769 + /* 3 bits per Node priority to TC 0-7, 4th byte reserved */ 770 + __le32 tc_node_prio; 771 + #define ICE_TC_NODE_PRIO_S 0x4 772 + u8 reserved1[4]; 773 + __le32 tc_node_teid[8]; /* Used for response, reserved in command */ 774 + }; 775 + 750 776 /* Query Scheduler Resource Allocation (indirect 0x0412) 751 777 * This indirect command retrieves the scheduler resources allocated by 752 778 * EMP Firmware to the given PF. ··· 1050 1024 u8 ext_info; 1051 1025 #define ICE_AQ_LINK_PHY_TEMP_ALARM BIT(0) 1052 1026 #define ICE_AQ_LINK_EXCESSIVE_ERRORS BIT(1) /* Excessive Link Errors */ 1053 - /* Port TX Suspended */ 1027 + /* Port Tx Suspended */ 1054 1028 #define ICE_AQ_LINK_TX_S 2 1055 1029 #define ICE_AQ_LINK_TX_M (0x03 << ICE_AQ_LINK_TX_S) 1056 1030 #define ICE_AQ_LINK_TX_ACTIVE 0 ··· 1146 1120 }; 1147 1121 1148 1122 /** 1149 - * Send to PF command (indirect 0x0801) id is only used by PF 1123 + * Send to PF command (indirect 0x0801) ID is only used by PF 1150 1124 * 1151 - * Send to VF command (indirect 0x0802) id is only used by PF 1125 + * Send to VF command (indirect 0x0802) ID is only used by PF 1152 1126 * 1153 1127 */ 1154 1128 struct ice_aqc_pf_vf_msg { ··· 1156 1130 u32 reserved; 1157 1131 __le32 addr_high; 1158 1132 __le32 addr_low; 1133 + }; 1134 + 1135 + /* Get LLDP MIB (indirect 0x0A00) 1136 + * Note: This is also used by the LLDP MIB Change Event (0x0A01) 1137 + * as the format is the same. 1138 + */ 1139 + struct ice_aqc_lldp_get_mib { 1140 + u8 type; 1141 + #define ICE_AQ_LLDP_MIB_TYPE_S 0 1142 + #define ICE_AQ_LLDP_MIB_TYPE_M (0x3 << ICE_AQ_LLDP_MIB_TYPE_S) 1143 + #define ICE_AQ_LLDP_MIB_LOCAL 0 1144 + #define ICE_AQ_LLDP_MIB_REMOTE 1 1145 + #define ICE_AQ_LLDP_MIB_LOCAL_AND_REMOTE 2 1146 + #define ICE_AQ_LLDP_BRID_TYPE_S 2 1147 + #define ICE_AQ_LLDP_BRID_TYPE_M (0x3 << ICE_AQ_LLDP_BRID_TYPE_S) 1148 + #define ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID 0 1149 + #define ICE_AQ_LLDP_BRID_TYPE_NON_TPMR 1 1150 + /* Tx pause flags in the 0xA01 event use ICE_AQ_LLDP_TX_* */ 1151 + #define ICE_AQ_LLDP_TX_S 0x4 1152 + #define ICE_AQ_LLDP_TX_M (0x03 << ICE_AQ_LLDP_TX_S) 1153 + #define ICE_AQ_LLDP_TX_ACTIVE 0 1154 + #define ICE_AQ_LLDP_TX_SUSPENDED 1 1155 + #define ICE_AQ_LLDP_TX_FLUSHED 3 1156 + /* The following bytes are reserved for the Get LLDP MIB command (0x0A00) 1157 + * and in the LLDP MIB Change Event (0x0A01). They are valid for the 1158 + * Get LLDP MIB (0x0A00) response only. 1159 + */ 1160 + u8 reserved1; 1161 + __le16 local_len; 1162 + __le16 remote_len; 1163 + u8 reserved2[2]; 1164 + __le32 addr_high; 1165 + __le32 addr_low; 1166 + }; 1167 + 1168 + /* Configure LLDP MIB Change Event (direct 0x0A01) */ 1169 + /* For MIB Change Event use ice_aqc_lldp_get_mib structure above */ 1170 + struct ice_aqc_lldp_set_mib_change { 1171 + u8 command; 1172 + #define ICE_AQ_LLDP_MIB_UPDATE_ENABLE 0x0 1173 + #define ICE_AQ_LLDP_MIB_UPDATE_DIS 0x1 1174 + u8 reserved[15]; 1175 + }; 1176 + 1177 + /* Stop LLDP (direct 0x0A05) */ 1178 + struct ice_aqc_lldp_stop { 1179 + u8 command; 1180 + #define ICE_AQ_LLDP_AGENT_STATE_MASK BIT(0) 1181 + #define ICE_AQ_LLDP_AGENT_STOP 0x0 1182 + #define ICE_AQ_LLDP_AGENT_SHUTDOWN ICE_AQ_LLDP_AGENT_STATE_MASK 1183 + #define ICE_AQ_LLDP_AGENT_PERSIST_DIS BIT(1) 1184 + u8 reserved[15]; 1185 + }; 1186 + 1187 + /* Start LLDP (direct 0x0A06) */ 1188 + struct ice_aqc_lldp_start { 1189 + u8 command; 1190 + #define ICE_AQ_LLDP_AGENT_START BIT(0) 1191 + #define ICE_AQ_LLDP_AGENT_PERSIST_ENA BIT(1) 1192 + u8 reserved[15]; 1193 + }; 1194 + 1195 + /* Get CEE DCBX Oper Config (0x0A07) 1196 + * The command uses the generic descriptor struct and 1197 + * returns the struct below as an indirect response. 1198 + */ 1199 + struct ice_aqc_get_cee_dcb_cfg_resp { 1200 + u8 oper_num_tc; 1201 + u8 oper_prio_tc[4]; 1202 + u8 oper_tc_bw[8]; 1203 + u8 oper_pfc_en; 1204 + __le16 oper_app_prio; 1205 + #define ICE_AQC_CEE_APP_FCOE_S 0 1206 + #define ICE_AQC_CEE_APP_FCOE_M (0x7 << ICE_AQC_CEE_APP_FCOE_S) 1207 + #define ICE_AQC_CEE_APP_ISCSI_S 3 1208 + #define ICE_AQC_CEE_APP_ISCSI_M (0x7 << ICE_AQC_CEE_APP_ISCSI_S) 1209 + #define ICE_AQC_CEE_APP_FIP_S 8 1210 + #define ICE_AQC_CEE_APP_FIP_M (0x7 << ICE_AQC_CEE_APP_FIP_S) 1211 + __le32 tlv_status; 1212 + #define ICE_AQC_CEE_PG_STATUS_S 0 1213 + #define ICE_AQC_CEE_PG_STATUS_M (0x7 << ICE_AQC_CEE_PG_STATUS_S) 1214 + #define ICE_AQC_CEE_PFC_STATUS_S 3 1215 + #define ICE_AQC_CEE_PFC_STATUS_M (0x7 << ICE_AQC_CEE_PFC_STATUS_S) 1216 + #define ICE_AQC_CEE_FCOE_STATUS_S 8 1217 + #define ICE_AQC_CEE_FCOE_STATUS_M (0x7 << ICE_AQC_CEE_FCOE_STATUS_S) 1218 + #define ICE_AQC_CEE_ISCSI_STATUS_S 11 1219 + #define ICE_AQC_CEE_ISCSI_STATUS_M (0x7 << ICE_AQC_CEE_ISCSI_STATUS_S) 1220 + #define ICE_AQC_CEE_FIP_STATUS_S 16 1221 + #define ICE_AQC_CEE_FIP_STATUS_M (0x7 << ICE_AQC_CEE_FIP_STATUS_S) 1222 + u8 reserved[12]; 1223 + }; 1224 + 1225 + /* Set Local LLDP MIB (indirect 0x0A08) 1226 + * Used to replace the local MIB of a given LLDP agent. e.g. DCBx 1227 + */ 1228 + struct ice_aqc_lldp_set_local_mib { 1229 + u8 type; 1230 + #define SET_LOCAL_MIB_TYPE_DCBX_M BIT(0) 1231 + #define SET_LOCAL_MIB_TYPE_LOCAL_MIB 0 1232 + #define SET_LOCAL_MIB_TYPE_CEE_M BIT(1) 1233 + #define SET_LOCAL_MIB_TYPE_CEE_WILLING 0 1234 + #define SET_LOCAL_MIB_TYPE_CEE_NON_WILLING SET_LOCAL_MIB_TYPE_CEE_M 1235 + u8 reserved0; 1236 + __le16 length; 1237 + u8 reserved1[4]; 1238 + __le32 addr_high; 1239 + __le32 addr_low; 1240 + }; 1241 + 1242 + /* Stop/Start LLDP Agent (direct 0x0A09) 1243 + * Used for stopping/starting specific LLDP agent. e.g. DCBx. 1244 + * The same structure is used for the response, with the command field 1245 + * being used as the status field. 1246 + */ 1247 + struct ice_aqc_lldp_stop_start_specific_agent { 1248 + u8 command; 1249 + #define ICE_AQC_START_STOP_AGENT_M BIT(0) 1250 + #define ICE_AQC_START_STOP_AGENT_STOP_DCBX 0 1251 + #define ICE_AQC_START_STOP_AGENT_START_DCBX ICE_AQC_START_STOP_AGENT_M 1252 + u8 reserved[15]; 1159 1253 }; 1160 1254 1161 1255 /* Get/Set RSS key (indirect 0x0B04/0x0B02) */ ··· 1332 1186 __le32 addr_low; 1333 1187 }; 1334 1188 1335 - /* Add TX LAN Queues (indirect 0x0C30) */ 1189 + /* Add Tx LAN Queues (indirect 0x0C30) */ 1336 1190 struct ice_aqc_add_txqs { 1337 1191 u8 num_qgrps; 1338 1192 u8 reserved[3]; ··· 1341 1195 __le32 addr_low; 1342 1196 }; 1343 1197 1344 - /* This is the descriptor of each queue entry for the Add TX LAN Queues 1198 + /* This is the descriptor of each queue entry for the Add Tx LAN Queues 1345 1199 * command (0x0C30). Only used within struct ice_aqc_add_tx_qgrp. 1346 1200 */ 1347 1201 struct ice_aqc_add_txqs_perq { ··· 1353 1207 struct ice_aqc_txsched_elem info; 1354 1208 }; 1355 1209 1356 - /* The format of the command buffer for Add TX LAN Queues (0x0C30) 1210 + /* The format of the command buffer for Add Tx LAN Queues (0x0C30) 1357 1211 * is an array of the following structs. Please note that the length of 1358 1212 * each struct ice_aqc_add_tx_qgrp is variable due 1359 1213 * to the variable number of queues in each group! ··· 1365 1219 struct ice_aqc_add_txqs_perq txqs[1]; 1366 1220 }; 1367 1221 1368 - /* Disable TX LAN Queues (indirect 0x0C31) */ 1222 + /* Disable Tx LAN Queues (indirect 0x0C31) */ 1369 1223 struct ice_aqc_dis_txqs { 1370 1224 u8 cmd_type; 1371 1225 #define ICE_AQC_Q_DIS_CMD_S 0 ··· 1387 1241 __le32 addr_low; 1388 1242 }; 1389 1243 1390 - /* The buffer for Disable TX LAN Queues (indirect 0x0C31) 1244 + /* The buffer for Disable Tx LAN Queues (indirect 0x0C31) 1391 1245 * contains the following structures, arrayed one after the 1392 1246 * other. 1393 1247 * Note: Since the q_id is 16 bits wide, if the ··· 1534 1388 struct ice_aqc_get_topo get_topo; 1535 1389 struct ice_aqc_sched_elem_cmd sched_elem_cmd; 1536 1390 struct ice_aqc_query_txsched_res query_sched_res; 1391 + struct ice_aqc_query_port_ets port_ets; 1537 1392 struct ice_aqc_nvm nvm; 1538 1393 struct ice_aqc_pf_vf_msg virt; 1394 + struct ice_aqc_lldp_get_mib lldp_get_mib; 1395 + struct ice_aqc_lldp_set_mib_change lldp_set_event; 1396 + struct ice_aqc_lldp_stop lldp_stop; 1397 + struct ice_aqc_lldp_start lldp_start; 1398 + struct ice_aqc_lldp_set_local_mib lldp_set_mib; 1399 + struct ice_aqc_lldp_stop_start_specific_agent lldp_agent_ctrl; 1539 1400 struct ice_aqc_get_set_rss_lut get_set_rss_lut; 1540 1401 struct ice_aqc_get_set_rss_key get_set_rss_key; 1541 1402 struct ice_aqc_add_txqs add_txqs; ··· 1575 1422 /* error codes */ 1576 1423 enum ice_aq_err { 1577 1424 ICE_AQ_RC_OK = 0, /* Success */ 1425 + ICE_AQ_RC_EPERM = 1, /* Operation not permitted */ 1426 + ICE_AQ_RC_ENOENT = 2, /* No such element */ 1578 1427 ICE_AQ_RC_ENOMEM = 9, /* Out of memory */ 1579 1428 ICE_AQ_RC_EBUSY = 12, /* Device or resource busy */ 1580 1429 ICE_AQ_RC_EEXIST = 13, /* Object already exists */ ··· 1629 1474 ice_aqc_opc_get_sched_elems = 0x0404, 1630 1475 ice_aqc_opc_suspend_sched_elems = 0x0409, 1631 1476 ice_aqc_opc_resume_sched_elems = 0x040A, 1477 + ice_aqc_opc_query_port_ets = 0x040E, 1632 1478 ice_aqc_opc_delete_sched_elems = 0x040F, 1633 1479 ice_aqc_opc_query_sched_res = 0x0412, 1634 1480 ··· 1647 1491 /* PF/VF mailbox commands */ 1648 1492 ice_mbx_opc_send_msg_to_pf = 0x0801, 1649 1493 ice_mbx_opc_send_msg_to_vf = 0x0802, 1494 + /* LLDP commands */ 1495 + ice_aqc_opc_lldp_get_mib = 0x0A00, 1496 + ice_aqc_opc_lldp_set_mib_change = 0x0A01, 1497 + ice_aqc_opc_lldp_stop = 0x0A05, 1498 + ice_aqc_opc_lldp_start = 0x0A06, 1499 + ice_aqc_opc_get_cee_dcb_cfg = 0x0A07, 1500 + ice_aqc_opc_lldp_set_local_mib = 0x0A08, 1501 + ice_aqc_opc_lldp_stop_start_specific_agent = 0x0A09, 1650 1502 1651 1503 /* RSS commands */ 1652 1504 ice_aqc_opc_set_rss_key = 0x0B02, ··· 1662 1498 ice_aqc_opc_get_rss_key = 0x0B04, 1663 1499 ice_aqc_opc_get_rss_lut = 0x0B05, 1664 1500 1665 - /* TX queue handling commands/events */ 1501 + /* Tx queue handling commands/events */ 1666 1502 ice_aqc_opc_add_txqs = 0x0C30, 1667 1503 ice_aqc_opc_dis_txqs = 0x0C31, 1668 1504
+75 -50
drivers/net/ethernet/intel/ice/ice_common.c
··· 31 31 * @hw: pointer to the HW structure 32 32 * 33 33 * This function sets the MAC type of the adapter based on the 34 - * vendor ID and device ID stored in the hw structure. 34 + * vendor ID and device ID stored in the HW structure. 35 35 */ 36 36 static enum ice_status ice_set_mac_type(struct ice_hw *hw) 37 37 { ··· 77 77 78 78 /** 79 79 * ice_aq_manage_mac_read - manage MAC address read command 80 - * @hw: pointer to the hw struct 80 + * @hw: pointer to the HW struct 81 81 * @buf: a virtual buffer to hold the manage MAC read response 82 82 * @buf_size: Size of the virtual buffer 83 83 * @cd: pointer to command details structure or NULL ··· 418 418 419 419 /** 420 420 * ice_init_fltr_mgmt_struct - initializes filter management list and locks 421 - * @hw: pointer to the hw struct 421 + * @hw: pointer to the HW struct 422 422 */ 423 423 static enum ice_status ice_init_fltr_mgmt_struct(struct ice_hw *hw) 424 424 { ··· 438 438 439 439 /** 440 440 * ice_cleanup_fltr_mgmt_struct - cleanup filter management list and locks 441 - * @hw: pointer to the hw struct 441 + * @hw: pointer to the HW struct 442 442 */ 443 443 static void ice_cleanup_fltr_mgmt_struct(struct ice_hw *hw) 444 444 { ··· 477 477 478 478 /** 479 479 * ice_cfg_fw_log - configure FW logging 480 - * @hw: pointer to the hw struct 480 + * @hw: pointer to the HW struct 481 481 * @enable: enable certain FW logging events if true, disable all if false 482 482 * 483 483 * This function enables/disables the FW logging via Rx CQ events and a UART ··· 626 626 627 627 /** 628 628 * ice_output_fw_log 629 - * @hw: pointer to the hw struct 629 + * @hw: pointer to the HW struct 630 630 * @desc: pointer to the AQ message descriptor 631 631 * @buf: pointer to the buffer accompanying the AQ message 632 632 * ··· 642 642 643 643 /** 644 644 * ice_get_itr_intrl_gran - determine int/intrl granularity 645 - * @hw: pointer to the hw struct 645 + * @hw: pointer to the HW struct 646 646 * 647 647 * Determines the itr/intrl granularities based on the maximum aggregate 648 648 * bandwidth according to the device's configuration during power-on. ··· 731 731 goto err_unroll_cqinit; 732 732 } 733 733 734 - /* set the back pointer to hw */ 734 + /* set the back pointer to HW */ 735 735 hw->port_info->hw = hw; 736 736 737 737 /* Initialize port_info struct with switch configuration data */ ··· 988 988 * @ice_rxq_ctx: pointer to the rxq context 989 989 * @rxq_index: the index of the Rx queue 990 990 * 991 - * Copies rxq context from dense structure to hw register space 991 + * Copies rxq context from dense structure to HW register space 992 992 */ 993 993 static enum ice_status 994 994 ice_copy_rxq_ctx_to_hw(struct ice_hw *hw, u8 *ice_rxq_ctx, u32 rxq_index) ··· 1001 1001 if (rxq_index > QRX_CTRL_MAX_INDEX) 1002 1002 return ICE_ERR_PARAM; 1003 1003 1004 - /* Copy each dword separately to hw */ 1004 + /* Copy each dword separately to HW */ 1005 1005 for (i = 0; i < ICE_RXQ_CTX_SIZE_DWORDS; i++) { 1006 1006 wr32(hw, QRX_CONTEXT(i, rxq_index), 1007 1007 *((u32 *)(ice_rxq_ctx + (i * sizeof(u32))))); ··· 1045 1045 * @rxq_index: the index of the Rx queue 1046 1046 * 1047 1047 * Converts rxq context from sparse to dense structure and then writes 1048 - * it to hw register space 1048 + * it to HW register space 1049 1049 */ 1050 1050 enum ice_status 1051 1051 ice_write_rxq_ctx(struct ice_hw *hw, struct ice_rlan_ctx *rlan_ctx, ··· 1144 1144 1145 1145 /** 1146 1146 * ice_aq_send_cmd - send FW Admin Queue command to FW Admin Queue 1147 - * @hw: pointer to the hw struct 1147 + * @hw: pointer to the HW struct 1148 1148 * @desc: descriptor describing the command 1149 1149 * @buf: buffer to use for indirect commands (NULL for direct commands) 1150 1150 * @buf_size: size of buffer for indirect commands (0 for direct commands) ··· 1161 1161 1162 1162 /** 1163 1163 * ice_aq_get_fw_ver 1164 - * @hw: pointer to the hw struct 1164 + * @hw: pointer to the HW struct 1165 1165 * @cd: pointer to command details structure or NULL 1166 1166 * 1167 1167 * Get the firmware version (0x0001) from the admin queue commands ··· 1195 1195 1196 1196 /** 1197 1197 * ice_aq_q_shutdown 1198 - * @hw: pointer to the hw struct 1198 + * @hw: pointer to the HW struct 1199 1199 * @unloading: is the driver unloading itself 1200 1200 * 1201 1201 * Tell the Firmware that we're shutting down the AdminQ and whether ··· 1218 1218 1219 1219 /** 1220 1220 * ice_aq_req_res 1221 - * @hw: pointer to the hw struct 1222 - * @res: resource id 1221 + * @hw: pointer to the HW struct 1222 + * @res: resource ID 1223 1223 * @access: access type 1224 1224 * @sdp_number: resource number 1225 1225 * @timeout: the maximum time in ms that the driver may hold the resource ··· 1304 1304 1305 1305 /** 1306 1306 * ice_aq_release_res 1307 - * @hw: pointer to the hw struct 1308 - * @res: resource id 1307 + * @hw: pointer to the HW struct 1308 + * @res: resource ID 1309 1309 * @sdp_number: resource number 1310 1310 * @cd: pointer to command details structure or NULL 1311 1311 * ··· 1331 1331 /** 1332 1332 * ice_acquire_res 1333 1333 * @hw: pointer to the HW structure 1334 - * @res: resource id 1334 + * @res: resource ID 1335 1335 * @access: access type (read or write) 1336 1336 * @timeout: timeout in milliseconds 1337 1337 * ··· 1393 1393 /** 1394 1394 * ice_release_res 1395 1395 * @hw: pointer to the HW structure 1396 - * @res: resource id 1396 + * @res: resource ID 1397 1397 * 1398 1398 * This function will release a resource using the proper Admin Command. 1399 1399 */ ··· 1405 1405 status = ice_aq_release_res(hw, res, 0, NULL); 1406 1406 1407 1407 /* there are some rare cases when trying to release the resource 1408 - * results in an admin Q timeout, so handle them correctly 1408 + * results in an admin queue timeout, so handle them correctly 1409 1409 */ 1410 1410 while ((status == ICE_ERR_AQ_TIMEOUT) && 1411 1411 (total_delay < hw->adminq.sq_cmd_timeout)) { ··· 1417 1417 1418 1418 /** 1419 1419 * ice_get_num_per_func - determine number of resources per PF 1420 - * @hw: pointer to the hw structure 1420 + * @hw: pointer to the HW structure 1421 1421 * @max: value to be evenly split between each PF 1422 1422 * 1423 1423 * Determine the number of valid functions by going through the bitmap returned ··· 1440 1440 1441 1441 /** 1442 1442 * ice_parse_caps - parse function/device capabilities 1443 - * @hw: pointer to the hw struct 1443 + * @hw: pointer to the HW struct 1444 1444 * @buf: pointer to a buffer containing function/device capability records 1445 1445 * @cap_count: number of capability records in the list 1446 1446 * @opc: type of capabilities list to parse ··· 1582 1582 1583 1583 /** 1584 1584 * ice_aq_discover_caps - query function/device capabilities 1585 - * @hw: pointer to the hw struct 1585 + * @hw: pointer to the HW struct 1586 1586 * @buf: a virtual buffer to hold the capabilities 1587 1587 * @buf_size: Size of the virtual buffer 1588 1588 * @cap_count: cap count needed if AQ err==ENOMEM ··· 1681 1681 1682 1682 /** 1683 1683 * ice_aq_manage_mac_write - manage MAC address write command 1684 - * @hw: pointer to the hw struct 1684 + * @hw: pointer to the HW struct 1685 1685 * @mac_addr: MAC address to be written as LAA/LAA+WoL/Port address 1686 1686 * @flags: flags to control write behavior 1687 1687 * @cd: pointer to command details structure or NULL ··· 1709 1709 1710 1710 /** 1711 1711 * ice_aq_clear_pxe_mode 1712 - * @hw: pointer to the hw struct 1712 + * @hw: pointer to the HW struct 1713 1713 * 1714 1714 * Tell the firmware that the driver is taking over from PXE (0x0110). 1715 1715 */ ··· 1725 1725 1726 1726 /** 1727 1727 * ice_clear_pxe_mode - clear pxe operations mode 1728 - * @hw: pointer to the hw struct 1728 + * @hw: pointer to the HW struct 1729 1729 * 1730 1730 * Make sure all PXE mode settings are cleared, including things 1731 1731 * like descriptor fetch/write-back mode. ··· 1741 1741 * @phy_type_low: lower part of phy_type 1742 1742 * @phy_type_high: higher part of phy_type 1743 1743 * 1744 - * This helper function will convert an entry in phy type structure 1744 + * This helper function will convert an entry in PHY type structure 1745 1745 * [phy_type_low, phy_type_high] to its corresponding link speed. 1746 1746 * Note: In the structure of [phy_type_low, phy_type_high], there should 1747 - * be one bit set, as this function will convert one phy type to its 1747 + * be one bit set, as this function will convert one PHY type to its 1748 1748 * speed. 1749 1749 * If no bit gets set, ICE_LINK_SPEED_UNKNOWN will be returned 1750 1750 * If more than one bit gets set, ICE_LINK_SPEED_UNKNOWN will be returned ··· 1914 1914 1915 1915 /** 1916 1916 * ice_aq_set_phy_cfg 1917 - * @hw: pointer to the hw struct 1917 + * @hw: pointer to the HW struct 1918 1918 * @lport: logical port number 1919 1919 * @cfg: structure with PHY configuration data to be set 1920 1920 * @cd: pointer to command details structure or NULL ··· 2029 2029 if (!pcaps) 2030 2030 return ICE_ERR_NO_MEMORY; 2031 2031 2032 - /* Get the current phy config */ 2032 + /* Get the current PHY config */ 2033 2033 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_SW_CFG, pcaps, 2034 2034 NULL); 2035 2035 if (status) { ··· 2338 2338 2339 2339 /** 2340 2340 * __ice_aq_get_set_rss_key 2341 - * @hw: pointer to the hw struct 2341 + * @hw: pointer to the HW struct 2342 2342 * @vsi_id: VSI FW index 2343 2343 * @key: pointer to key info struct 2344 2344 * @set: set true to set the key, false to get the key ··· 2373 2373 2374 2374 /** 2375 2375 * ice_aq_get_rss_key 2376 - * @hw: pointer to the hw struct 2376 + * @hw: pointer to the HW struct 2377 2377 * @vsi_handle: software VSI handle 2378 2378 * @key: pointer to key info struct 2379 2379 * ··· 2392 2392 2393 2393 /** 2394 2394 * ice_aq_set_rss_key 2395 - * @hw: pointer to the hw struct 2395 + * @hw: pointer to the HW struct 2396 2396 * @vsi_handle: software VSI handle 2397 2397 * @keys: pointer to key info struct 2398 2398 * ··· 2477 2477 * @num_qgrps: number of groups in the list 2478 2478 * @qg_list: the list of groups to disable 2479 2479 * @buf_size: the total size of the qg_list buffer in bytes 2480 - * @rst_src: if called due to reset, specifies the RST source 2480 + * @rst_src: if called due to reset, specifies the reset source 2481 2481 * @vmvf_num: the relative VM or VF number that is undergoing the reset 2482 2482 * @cd: pointer to command details structure or NULL 2483 2483 * ··· 2517 2517 break; 2518 2518 case ICE_VF_RESET: 2519 2519 cmd->cmd_type = ICE_AQC_Q_DIS_CMD_VF_RESET; 2520 - /* In this case, FW expects vmvf_num to be absolute VF id */ 2520 + /* In this case, FW expects vmvf_num to be absolute VF ID */ 2521 2521 cmd->vmvf_and_timeout |= 2522 2522 cpu_to_le16((vmvf_num + hw->func_caps.vf_base_id) & 2523 2523 ICE_AQC_Q_DIS_VMVF_NUM_M); ··· 2794 2794 * ice_ena_vsi_txq 2795 2795 * @pi: port information structure 2796 2796 * @vsi_handle: software VSI handle 2797 - * @tc: tc number 2797 + * @tc: TC number 2798 2798 * @num_qgrps: Number of added queue groups 2799 2799 * @buf: list of queue groups to be added 2800 2800 * @buf_size: size of buffer for indirect command 2801 2801 * @cd: pointer to command details structure or NULL 2802 2802 * 2803 - * This function adds one lan q 2803 + * This function adds one LAN queue 2804 2804 */ 2805 2805 enum ice_status 2806 2806 ice_ena_vsi_txq(struct ice_port_info *pi, u16 vsi_handle, u8 tc, u8 num_qgrps, ··· 2844 2844 * Bit 5-6. 2845 2845 * - Bit 7 is reserved. 2846 2846 * Without setting the generic section as valid in valid_sections, the 2847 - * Admin Q command will fail with error code ICE_AQ_RC_EINVAL. 2847 + * Admin queue command will fail with error code ICE_AQ_RC_EINVAL. 2848 2848 */ 2849 2849 buf->txqs[0].info.valid_sections = ICE_AQC_ELEM_VALID_GENERIC; 2850 2850 2851 - /* add the lan q */ 2851 + /* add the LAN queue */ 2852 2852 status = ice_aq_add_lan_txq(hw, num_qgrps, buf, buf_size, cd); 2853 2853 if (status) { 2854 2854 ice_debug(hw, ICE_DBG_SCHED, "enable Q %d failed %d\n", ··· 2860 2860 node.node_teid = buf->txqs[0].q_teid; 2861 2861 node.data.elem_type = ICE_AQC_ELEM_TYPE_LEAF; 2862 2862 2863 - /* add a leaf node into schduler tree q layer */ 2863 + /* add a leaf node into schduler tree queue layer */ 2864 2864 status = ice_sched_add_node(pi, hw->num_tx_sched_layers - 1, &node); 2865 2865 2866 2866 ena_txq_exit: ··· 2874 2874 * @num_queues: number of queues 2875 2875 * @q_ids: pointer to the q_id array 2876 2876 * @q_teids: pointer to queue node teids 2877 - * @rst_src: if called due to reset, specifies the RST source 2877 + * @rst_src: if called due to reset, specifies the reset source 2878 2878 * @vmvf_num: the relative VM or VF number that is undergoing the reset 2879 2879 * @cd: pointer to command details structure or NULL 2880 2880 * ··· 2925 2925 } 2926 2926 2927 2927 /** 2928 - * ice_cfg_vsi_qs - configure the new/exisiting VSI queues 2928 + * ice_cfg_vsi_qs - configure the new/existing VSI queues 2929 2929 * @pi: port information structure 2930 2930 * @vsi_handle: software VSI handle 2931 2931 * @tc_bitmap: TC bitmap 2932 2932 * @maxqs: max queues array per TC 2933 - * @owner: lan or rdma 2933 + * @owner: LAN or RDMA 2934 2934 * 2935 2935 * This function adds/updates the VSI queues per TC. 2936 2936 */ ··· 2965 2965 } 2966 2966 2967 2967 /** 2968 - * ice_cfg_vsi_lan - configure VSI lan queues 2968 + * ice_cfg_vsi_lan - configure VSI LAN queues 2969 2969 * @pi: port information structure 2970 2970 * @vsi_handle: software VSI handle 2971 2971 * @tc_bitmap: TC bitmap 2972 - * @max_lanqs: max lan queues array per TC 2972 + * @max_lanqs: max LAN queues array per TC 2973 2973 * 2974 - * This function adds/updates the VSI lan queues per TC. 2974 + * This function adds/updates the VSI LAN queues per TC. 2975 2975 */ 2976 2976 enum ice_status 2977 2977 ice_cfg_vsi_lan(struct ice_port_info *pi, u16 vsi_handle, u8 tc_bitmap, ··· 2983 2983 2984 2984 /** 2985 2985 * ice_replay_pre_init - replay pre initialization 2986 - * @hw: pointer to the hw struct 2986 + * @hw: pointer to the HW struct 2987 2987 * 2988 2988 * Initializes required config data for VSI, FD, ACL, and RSS before replay. 2989 2989 */ ··· 3007 3007 3008 3008 /** 3009 3009 * ice_replay_vsi - replay VSI configuration 3010 - * @hw: pointer to the hw struct 3010 + * @hw: pointer to the HW struct 3011 3011 * @vsi_handle: driver VSI handle 3012 3012 * 3013 3013 * Restore all VSI configuration after reset. It is required to call this ··· 3034 3034 3035 3035 /** 3036 3036 * ice_replay_post - post replay configuration cleanup 3037 - * @hw: pointer to the hw struct 3037 + * @hw: pointer to the HW struct 3038 3038 * 3039 3039 * Post replay cleanup. 3040 3040 */ ··· 3105 3105 else 3106 3106 /* to manage the potential roll-over */ 3107 3107 *cur_stat = (new_data + BIT_ULL(32)) - *prev_stat; 3108 + } 3109 + 3110 + /** 3111 + * ice_sched_query_elem - query element information from HW 3112 + * @hw: pointer to the HW struct 3113 + * @node_teid: node TEID to be queried 3114 + * @buf: buffer to element information 3115 + * 3116 + * This function queries HW element information 3117 + */ 3118 + enum ice_status 3119 + ice_sched_query_elem(struct ice_hw *hw, u32 node_teid, 3120 + struct ice_aqc_get_elem *buf) 3121 + { 3122 + u16 buf_size, num_elem_ret = 0; 3123 + enum ice_status status; 3124 + 3125 + buf_size = sizeof(*buf); 3126 + memset(buf, 0, buf_size); 3127 + buf->generic[0].node_teid = cpu_to_le32(node_teid); 3128 + status = ice_aq_query_sched_elems(hw, 1, buf, buf_size, &num_elem_ret, 3129 + NULL); 3130 + if (status || num_elem_ret != 1) 3131 + ice_debug(hw, ICE_DBG_SCHED, "query element failed\n"); 3132 + return status; 3108 3133 }
+3
drivers/net/ethernet/intel/ice/ice_common.h
··· 118 118 void 119 119 ice_stat_update32(struct ice_hw *hw, u32 reg, bool prev_stat_loaded, 120 120 u64 *prev_stat, u64 *cur_stat); 121 + enum ice_status 122 + ice_sched_query_elem(struct ice_hw *hw, u32 node_teid, 123 + struct ice_aqc_get_elem *buf); 121 124 #endif /* _ICE_COMMON_H_ */
+5 -5
drivers/net/ethernet/intel/ice/ice_controlq.c
··· 51 51 52 52 /** 53 53 * ice_check_sq_alive 54 - * @hw: pointer to the hw struct 54 + * @hw: pointer to the HW struct 55 55 * @cq: pointer to the specific Control queue 56 56 * 57 57 * Returns true if Queue is enabled else false. ··· 287 287 * @hw: pointer to the hardware structure 288 288 * @cq: pointer to the specific Control queue 289 289 * 290 - * Configure base address and length registers for the receive (event q) 290 + * Configure base address and length registers for the receive (event queue) 291 291 */ 292 292 static enum ice_status 293 293 ice_cfg_rq_regs(struct ice_hw *hw, struct ice_ctl_q_info *cq) ··· 751 751 752 752 /** 753 753 * ice_sq_done - check if FW has processed the Admin Send Queue (ATQ) 754 - * @hw: pointer to the hw struct 754 + * @hw: pointer to the HW struct 755 755 * @cq: pointer to the specific Control queue 756 756 * 757 757 * Returns true if the firmware has processed all descriptors on the ··· 767 767 768 768 /** 769 769 * ice_sq_send_cmd - send command to Control Queue (ATQ) 770 - * @hw: pointer to the hw struct 770 + * @hw: pointer to the HW struct 771 771 * @cq: pointer to the specific Control queue 772 772 * @desc: prefilled descriptor describing the command (non DMA mem) 773 773 * @buf: buffer to use for indirect commands (or NULL for direct commands) ··· 962 962 963 963 /** 964 964 * ice_clean_rq_elem 965 - * @hw: pointer to the hw struct 965 + * @hw: pointer to the HW struct 966 966 * @cq: pointer to the specific Control queue 967 967 * @e: event info from the receive descriptor, includes any buffers 968 968 * @pending: number of events that could be left to process
+1392
drivers/net/ethernet/intel/ice/ice_dcb.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2019, Intel Corporation. */ 3 + 4 + #include "ice_common.h" 5 + #include "ice_sched.h" 6 + #include "ice_dcb.h" 7 + 8 + /** 9 + * ice_aq_get_lldp_mib 10 + * @hw: pointer to the HW struct 11 + * @bridge_type: type of bridge requested 12 + * @mib_type: Local, Remote or both Local and Remote MIBs 13 + * @buf: pointer to the caller-supplied buffer to store the MIB block 14 + * @buf_size: size of the buffer (in bytes) 15 + * @local_len: length of the returned Local LLDP MIB 16 + * @remote_len: length of the returned Remote LLDP MIB 17 + * @cd: pointer to command details structure or NULL 18 + * 19 + * Requests the complete LLDP MIB (entire packet). (0x0A00) 20 + */ 21 + static enum ice_status 22 + ice_aq_get_lldp_mib(struct ice_hw *hw, u8 bridge_type, u8 mib_type, void *buf, 23 + u16 buf_size, u16 *local_len, u16 *remote_len, 24 + struct ice_sq_cd *cd) 25 + { 26 + struct ice_aqc_lldp_get_mib *cmd; 27 + struct ice_aq_desc desc; 28 + enum ice_status status; 29 + 30 + cmd = &desc.params.lldp_get_mib; 31 + 32 + if (buf_size == 0 || !buf) 33 + return ICE_ERR_PARAM; 34 + 35 + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_get_mib); 36 + 37 + cmd->type = mib_type & ICE_AQ_LLDP_MIB_TYPE_M; 38 + cmd->type |= (bridge_type << ICE_AQ_LLDP_BRID_TYPE_S) & 39 + ICE_AQ_LLDP_BRID_TYPE_M; 40 + 41 + desc.datalen = cpu_to_le16(buf_size); 42 + 43 + status = ice_aq_send_cmd(hw, &desc, buf, buf_size, cd); 44 + if (!status) { 45 + if (local_len) 46 + *local_len = le16_to_cpu(cmd->local_len); 47 + if (remote_len) 48 + *remote_len = le16_to_cpu(cmd->remote_len); 49 + } 50 + 51 + return status; 52 + } 53 + 54 + /** 55 + * ice_aq_cfg_lldp_mib_change 56 + * @hw: pointer to the HW struct 57 + * @ena_update: Enable or Disable event posting 58 + * @cd: pointer to command details structure or NULL 59 + * 60 + * Enable or Disable posting of an event on ARQ when LLDP MIB 61 + * associated with the interface changes (0x0A01) 62 + */ 63 + enum ice_status 64 + ice_aq_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_update, 65 + struct ice_sq_cd *cd) 66 + { 67 + struct ice_aqc_lldp_set_mib_change *cmd; 68 + struct ice_aq_desc desc; 69 + 70 + cmd = &desc.params.lldp_set_event; 71 + 72 + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_set_mib_change); 73 + 74 + if (!ena_update) 75 + cmd->command |= ICE_AQ_LLDP_MIB_UPDATE_DIS; 76 + 77 + return ice_aq_send_cmd(hw, &desc, NULL, 0, cd); 78 + } 79 + 80 + /** 81 + * ice_aq_stop_lldp 82 + * @hw: pointer to the HW struct 83 + * @shutdown_lldp_agent: True if LLDP Agent needs to be Shutdown 84 + * False if LLDP Agent needs to be Stopped 85 + * @cd: pointer to command details structure or NULL 86 + * 87 + * Stop or Shutdown the embedded LLDP Agent (0x0A05) 88 + */ 89 + enum ice_status 90 + ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, 91 + struct ice_sq_cd *cd) 92 + { 93 + struct ice_aqc_lldp_stop *cmd; 94 + struct ice_aq_desc desc; 95 + 96 + cmd = &desc.params.lldp_stop; 97 + 98 + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_stop); 99 + 100 + if (shutdown_lldp_agent) 101 + cmd->command |= ICE_AQ_LLDP_AGENT_SHUTDOWN; 102 + 103 + return ice_aq_send_cmd(hw, &desc, NULL, 0, cd); 104 + } 105 + 106 + /** 107 + * ice_aq_start_lldp 108 + * @hw: pointer to the HW struct 109 + * @cd: pointer to command details structure or NULL 110 + * 111 + * Start the embedded LLDP Agent on all ports. (0x0A06) 112 + */ 113 + enum ice_status ice_aq_start_lldp(struct ice_hw *hw, struct ice_sq_cd *cd) 114 + { 115 + struct ice_aqc_lldp_start *cmd; 116 + struct ice_aq_desc desc; 117 + 118 + cmd = &desc.params.lldp_start; 119 + 120 + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_start); 121 + 122 + cmd->command = ICE_AQ_LLDP_AGENT_START; 123 + 124 + return ice_aq_send_cmd(hw, &desc, NULL, 0, cd); 125 + } 126 + 127 + /** 128 + * ice_aq_set_lldp_mib - Set the LLDP MIB 129 + * @hw: pointer to the HW struct 130 + * @mib_type: Local, Remote or both Local and Remote MIBs 131 + * @buf: pointer to the caller-supplied buffer to store the MIB block 132 + * @buf_size: size of the buffer (in bytes) 133 + * @cd: pointer to command details structure or NULL 134 + * 135 + * Set the LLDP MIB. (0x0A08) 136 + */ 137 + static enum ice_status 138 + ice_aq_set_lldp_mib(struct ice_hw *hw, u8 mib_type, void *buf, u16 buf_size, 139 + struct ice_sq_cd *cd) 140 + { 141 + struct ice_aqc_lldp_set_local_mib *cmd; 142 + struct ice_aq_desc desc; 143 + 144 + cmd = &desc.params.lldp_set_mib; 145 + 146 + if (buf_size == 0 || !buf) 147 + return ICE_ERR_PARAM; 148 + 149 + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_lldp_set_local_mib); 150 + 151 + desc.flags |= cpu_to_le16((u16)ICE_AQ_FLAG_RD); 152 + desc.datalen = cpu_to_le16(buf_size); 153 + 154 + cmd->type = mib_type; 155 + cmd->length = cpu_to_le16(buf_size); 156 + 157 + return ice_aq_send_cmd(hw, &desc, buf, buf_size, cd); 158 + } 159 + 160 + /** 161 + * ice_get_dcbx_status 162 + * @hw: pointer to the HW struct 163 + * 164 + * Get the DCBX status from the Firmware 165 + */ 166 + u8 ice_get_dcbx_status(struct ice_hw *hw) 167 + { 168 + u32 reg; 169 + 170 + reg = rd32(hw, PRTDCB_GENS); 171 + return (u8)((reg & PRTDCB_GENS_DCBX_STATUS_M) >> 172 + PRTDCB_GENS_DCBX_STATUS_S); 173 + } 174 + 175 + /** 176 + * ice_parse_ieee_ets_common_tlv 177 + * @buf: Data buffer to be parsed for ETS CFG/REC data 178 + * @ets_cfg: Container to store parsed data 179 + * 180 + * Parses the common data of IEEE 802.1Qaz ETS CFG/REC TLV 181 + */ 182 + static void 183 + ice_parse_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg) 184 + { 185 + u8 offset = 0; 186 + int i; 187 + 188 + /* Priority Assignment Table (4 octets) 189 + * Octets:| 1 | 2 | 3 | 4 | 190 + * ----------------------------------------- 191 + * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7| 192 + * ----------------------------------------- 193 + * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0| 194 + * ----------------------------------------- 195 + */ 196 + for (i = 0; i < 4; i++) { 197 + ets_cfg->prio_table[i * 2] = 198 + ((buf[offset] & ICE_IEEE_ETS_PRIO_1_M) >> 199 + ICE_IEEE_ETS_PRIO_1_S); 200 + ets_cfg->prio_table[i * 2 + 1] = 201 + ((buf[offset] & ICE_IEEE_ETS_PRIO_0_M) >> 202 + ICE_IEEE_ETS_PRIO_0_S); 203 + offset++; 204 + } 205 + 206 + /* TC Bandwidth Table (8 octets) 207 + * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 208 + * --------------------------------- 209 + * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7| 210 + * --------------------------------- 211 + * 212 + * TSA Assignment Table (8 octets) 213 + * Octets:| 9 | 10| 11| 12| 13| 14| 15| 16| 214 + * --------------------------------- 215 + * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7| 216 + * --------------------------------- 217 + */ 218 + ice_for_each_traffic_class(i) { 219 + ets_cfg->tcbwtable[i] = buf[offset]; 220 + ets_cfg->tsatable[i] = buf[ICE_MAX_TRAFFIC_CLASS + offset++]; 221 + } 222 + } 223 + 224 + /** 225 + * ice_parse_ieee_etscfg_tlv 226 + * @tlv: IEEE 802.1Qaz ETS CFG TLV 227 + * @dcbcfg: Local store to update ETS CFG data 228 + * 229 + * Parses IEEE 802.1Qaz ETS CFG TLV 230 + */ 231 + static void 232 + ice_parse_ieee_etscfg_tlv(struct ice_lldp_org_tlv *tlv, 233 + struct ice_dcbx_cfg *dcbcfg) 234 + { 235 + struct ice_dcb_ets_cfg *etscfg; 236 + u8 *buf = tlv->tlvinfo; 237 + 238 + /* First Octet post subtype 239 + * -------------------------- 240 + * |will-|CBS | Re- | Max | 241 + * |ing | |served| TCs | 242 + * -------------------------- 243 + * |1bit | 1bit|3 bits|3bits| 244 + */ 245 + etscfg = &dcbcfg->etscfg; 246 + etscfg->willing = ((buf[0] & ICE_IEEE_ETS_WILLING_M) >> 247 + ICE_IEEE_ETS_WILLING_S); 248 + etscfg->cbs = ((buf[0] & ICE_IEEE_ETS_CBS_M) >> ICE_IEEE_ETS_CBS_S); 249 + etscfg->maxtcs = ((buf[0] & ICE_IEEE_ETS_MAXTC_M) >> 250 + ICE_IEEE_ETS_MAXTC_S); 251 + 252 + /* Begin parsing at Priority Assignment Table (offset 1 in buf) */ 253 + ice_parse_ieee_ets_common_tlv(&buf[1], etscfg); 254 + } 255 + 256 + /** 257 + * ice_parse_ieee_etsrec_tlv 258 + * @tlv: IEEE 802.1Qaz ETS REC TLV 259 + * @dcbcfg: Local store to update ETS REC data 260 + * 261 + * Parses IEEE 802.1Qaz ETS REC TLV 262 + */ 263 + static void 264 + ice_parse_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv, 265 + struct ice_dcbx_cfg *dcbcfg) 266 + { 267 + u8 *buf = tlv->tlvinfo; 268 + 269 + /* Begin parsing at Priority Assignment Table (offset 1 in buf) */ 270 + ice_parse_ieee_ets_common_tlv(&buf[1], &dcbcfg->etsrec); 271 + } 272 + 273 + /** 274 + * ice_parse_ieee_pfccfg_tlv 275 + * @tlv: IEEE 802.1Qaz PFC CFG TLV 276 + * @dcbcfg: Local store to update PFC CFG data 277 + * 278 + * Parses IEEE 802.1Qaz PFC CFG TLV 279 + */ 280 + static void 281 + ice_parse_ieee_pfccfg_tlv(struct ice_lldp_org_tlv *tlv, 282 + struct ice_dcbx_cfg *dcbcfg) 283 + { 284 + u8 *buf = tlv->tlvinfo; 285 + 286 + /* ---------------------------------------- 287 + * |will-|MBC | Re- | PFC | PFC Enable | 288 + * |ing | |served| cap | | 289 + * ----------------------------------------- 290 + * |1bit | 1bit|2 bits|4bits| 1 octet | 291 + */ 292 + dcbcfg->pfc.willing = ((buf[0] & ICE_IEEE_PFC_WILLING_M) >> 293 + ICE_IEEE_PFC_WILLING_S); 294 + dcbcfg->pfc.mbc = ((buf[0] & ICE_IEEE_PFC_MBC_M) >> ICE_IEEE_PFC_MBC_S); 295 + dcbcfg->pfc.pfccap = ((buf[0] & ICE_IEEE_PFC_CAP_M) >> 296 + ICE_IEEE_PFC_CAP_S); 297 + dcbcfg->pfc.pfcena = buf[1]; 298 + } 299 + 300 + /** 301 + * ice_parse_ieee_app_tlv 302 + * @tlv: IEEE 802.1Qaz APP TLV 303 + * @dcbcfg: Local store to update APP PRIO data 304 + * 305 + * Parses IEEE 802.1Qaz APP PRIO TLV 306 + */ 307 + static void 308 + ice_parse_ieee_app_tlv(struct ice_lldp_org_tlv *tlv, 309 + struct ice_dcbx_cfg *dcbcfg) 310 + { 311 + u16 offset = 0; 312 + u16 typelen; 313 + int i = 0; 314 + u16 len; 315 + u8 *buf; 316 + 317 + typelen = ntohs(tlv->typelen); 318 + len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S); 319 + buf = tlv->tlvinfo; 320 + 321 + /* Removing sizeof(ouisubtype) and reserved byte from len. 322 + * Remaining len div 3 is number of APP TLVs. 323 + */ 324 + len -= (sizeof(tlv->ouisubtype) + 1); 325 + 326 + /* Move offset to App Priority Table */ 327 + offset++; 328 + 329 + /* Application Priority Table (3 octets) 330 + * Octets:| 1 | 2 | 3 | 331 + * ----------------------------------------- 332 + * |Priority|Rsrvd| Sel | Protocol ID | 333 + * ----------------------------------------- 334 + * Bits:|23 21|20 19|18 16|15 0| 335 + * ----------------------------------------- 336 + */ 337 + while (offset < len) { 338 + dcbcfg->app[i].priority = ((buf[offset] & 339 + ICE_IEEE_APP_PRIO_M) >> 340 + ICE_IEEE_APP_PRIO_S); 341 + dcbcfg->app[i].selector = ((buf[offset] & 342 + ICE_IEEE_APP_SEL_M) >> 343 + ICE_IEEE_APP_SEL_S); 344 + dcbcfg->app[i].prot_id = (buf[offset + 1] << 0x8) | 345 + buf[offset + 2]; 346 + /* Move to next app */ 347 + offset += 3; 348 + i++; 349 + if (i >= ICE_DCBX_MAX_APPS) 350 + break; 351 + } 352 + 353 + dcbcfg->numapps = i; 354 + } 355 + 356 + /** 357 + * ice_parse_ieee_tlv 358 + * @tlv: IEEE 802.1Qaz TLV 359 + * @dcbcfg: Local store to update ETS REC data 360 + * 361 + * Get the TLV subtype and send it to parsing function 362 + * based on the subtype value 363 + */ 364 + static void 365 + ice_parse_ieee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg) 366 + { 367 + u32 ouisubtype; 368 + u8 subtype; 369 + 370 + ouisubtype = ntohl(tlv->ouisubtype); 371 + subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >> 372 + ICE_LLDP_TLV_SUBTYPE_S); 373 + switch (subtype) { 374 + case ICE_IEEE_SUBTYPE_ETS_CFG: 375 + ice_parse_ieee_etscfg_tlv(tlv, dcbcfg); 376 + break; 377 + case ICE_IEEE_SUBTYPE_ETS_REC: 378 + ice_parse_ieee_etsrec_tlv(tlv, dcbcfg); 379 + break; 380 + case ICE_IEEE_SUBTYPE_PFC_CFG: 381 + ice_parse_ieee_pfccfg_tlv(tlv, dcbcfg); 382 + break; 383 + case ICE_IEEE_SUBTYPE_APP_PRI: 384 + ice_parse_ieee_app_tlv(tlv, dcbcfg); 385 + break; 386 + default: 387 + break; 388 + } 389 + } 390 + 391 + /** 392 + * ice_parse_cee_pgcfg_tlv 393 + * @tlv: CEE DCBX PG CFG TLV 394 + * @dcbcfg: Local store to update ETS CFG data 395 + * 396 + * Parses CEE DCBX PG CFG TLV 397 + */ 398 + static void 399 + ice_parse_cee_pgcfg_tlv(struct ice_cee_feat_tlv *tlv, 400 + struct ice_dcbx_cfg *dcbcfg) 401 + { 402 + struct ice_dcb_ets_cfg *etscfg; 403 + u8 *buf = tlv->tlvinfo; 404 + u16 offset = 0; 405 + int i; 406 + 407 + etscfg = &dcbcfg->etscfg; 408 + 409 + if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M) 410 + etscfg->willing = 1; 411 + 412 + etscfg->cbs = 0; 413 + /* Priority Group Table (4 octets) 414 + * Octets:| 1 | 2 | 3 | 4 | 415 + * ----------------------------------------- 416 + * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7| 417 + * ----------------------------------------- 418 + * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0| 419 + * ----------------------------------------- 420 + */ 421 + for (i = 0; i < 4; i++) { 422 + etscfg->prio_table[i * 2] = 423 + ((buf[offset] & ICE_CEE_PGID_PRIO_1_M) >> 424 + ICE_CEE_PGID_PRIO_1_S); 425 + etscfg->prio_table[i * 2 + 1] = 426 + ((buf[offset] & ICE_CEE_PGID_PRIO_0_M) >> 427 + ICE_CEE_PGID_PRIO_0_S); 428 + offset++; 429 + } 430 + 431 + /* PG Percentage Table (8 octets) 432 + * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 433 + * --------------------------------- 434 + * |pg0|pg1|pg2|pg3|pg4|pg5|pg6|pg7| 435 + * --------------------------------- 436 + */ 437 + ice_for_each_traffic_class(i) 438 + etscfg->tcbwtable[i] = buf[offset++]; 439 + 440 + /* Number of TCs supported (1 octet) */ 441 + etscfg->maxtcs = buf[offset]; 442 + } 443 + 444 + /** 445 + * ice_parse_cee_pfccfg_tlv 446 + * @tlv: CEE DCBX PFC CFG TLV 447 + * @dcbcfg: Local store to update PFC CFG data 448 + * 449 + * Parses CEE DCBX PFC CFG TLV 450 + */ 451 + static void 452 + ice_parse_cee_pfccfg_tlv(struct ice_cee_feat_tlv *tlv, 453 + struct ice_dcbx_cfg *dcbcfg) 454 + { 455 + u8 *buf = tlv->tlvinfo; 456 + 457 + if (tlv->en_will_err & ICE_CEE_FEAT_TLV_WILLING_M) 458 + dcbcfg->pfc.willing = 1; 459 + 460 + /* ------------------------ 461 + * | PFC Enable | PFC TCs | 462 + * ------------------------ 463 + * | 1 octet | 1 octet | 464 + */ 465 + dcbcfg->pfc.pfcena = buf[0]; 466 + dcbcfg->pfc.pfccap = buf[1]; 467 + } 468 + 469 + /** 470 + * ice_parse_cee_app_tlv 471 + * @tlv: CEE DCBX APP TLV 472 + * @dcbcfg: Local store to update APP PRIO data 473 + * 474 + * Parses CEE DCBX APP PRIO TLV 475 + */ 476 + static void 477 + ice_parse_cee_app_tlv(struct ice_cee_feat_tlv *tlv, struct ice_dcbx_cfg *dcbcfg) 478 + { 479 + u16 len, typelen, offset = 0; 480 + struct ice_cee_app_prio *app; 481 + u8 i; 482 + 483 + typelen = ntohs(tlv->hdr.typelen); 484 + len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S); 485 + 486 + dcbcfg->numapps = len / sizeof(*app); 487 + if (!dcbcfg->numapps) 488 + return; 489 + if (dcbcfg->numapps > ICE_DCBX_MAX_APPS) 490 + dcbcfg->numapps = ICE_DCBX_MAX_APPS; 491 + 492 + for (i = 0; i < dcbcfg->numapps; i++) { 493 + u8 up, selector; 494 + 495 + app = (struct ice_cee_app_prio *)(tlv->tlvinfo + offset); 496 + for (up = 0; up < ICE_MAX_USER_PRIORITY; up++) 497 + if (app->prio_map & BIT(up)) 498 + break; 499 + 500 + dcbcfg->app[i].priority = up; 501 + 502 + /* Get Selector from lower 2 bits, and convert to IEEE */ 503 + selector = (app->upper_oui_sel & ICE_CEE_APP_SELECTOR_M); 504 + switch (selector) { 505 + case ICE_CEE_APP_SEL_ETHTYPE: 506 + dcbcfg->app[i].selector = ICE_APP_SEL_ETHTYPE; 507 + break; 508 + case ICE_CEE_APP_SEL_TCPIP: 509 + dcbcfg->app[i].selector = ICE_APP_SEL_TCPIP; 510 + break; 511 + default: 512 + /* Keep selector as it is for unknown types */ 513 + dcbcfg->app[i].selector = selector; 514 + } 515 + 516 + dcbcfg->app[i].prot_id = ntohs(app->protocol); 517 + /* Move to next app */ 518 + offset += sizeof(*app); 519 + } 520 + } 521 + 522 + /** 523 + * ice_parse_cee_tlv 524 + * @tlv: CEE DCBX TLV 525 + * @dcbcfg: Local store to update DCBX config data 526 + * 527 + * Get the TLV subtype and send it to parsing function 528 + * based on the subtype value 529 + */ 530 + static void 531 + ice_parse_cee_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg) 532 + { 533 + struct ice_cee_feat_tlv *sub_tlv; 534 + u8 subtype, feat_tlv_count = 0; 535 + u16 len, tlvlen, typelen; 536 + u32 ouisubtype; 537 + 538 + ouisubtype = ntohl(tlv->ouisubtype); 539 + subtype = (u8)((ouisubtype & ICE_LLDP_TLV_SUBTYPE_M) >> 540 + ICE_LLDP_TLV_SUBTYPE_S); 541 + /* Return if not CEE DCBX */ 542 + if (subtype != ICE_CEE_DCBX_TYPE) 543 + return; 544 + 545 + typelen = ntohs(tlv->typelen); 546 + tlvlen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S); 547 + len = sizeof(tlv->typelen) + sizeof(ouisubtype) + 548 + sizeof(struct ice_cee_ctrl_tlv); 549 + /* Return if no CEE DCBX Feature TLVs */ 550 + if (tlvlen <= len) 551 + return; 552 + 553 + sub_tlv = (struct ice_cee_feat_tlv *)((char *)tlv + len); 554 + while (feat_tlv_count < ICE_CEE_MAX_FEAT_TYPE) { 555 + u16 sublen; 556 + 557 + typelen = ntohs(sub_tlv->hdr.typelen); 558 + sublen = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S); 559 + subtype = (u8)((typelen & ICE_LLDP_TLV_TYPE_M) >> 560 + ICE_LLDP_TLV_TYPE_S); 561 + switch (subtype) { 562 + case ICE_CEE_SUBTYPE_PG_CFG: 563 + ice_parse_cee_pgcfg_tlv(sub_tlv, dcbcfg); 564 + break; 565 + case ICE_CEE_SUBTYPE_PFC_CFG: 566 + ice_parse_cee_pfccfg_tlv(sub_tlv, dcbcfg); 567 + break; 568 + case ICE_CEE_SUBTYPE_APP_PRI: 569 + ice_parse_cee_app_tlv(sub_tlv, dcbcfg); 570 + break; 571 + default: 572 + return; /* Invalid Sub-type return */ 573 + } 574 + feat_tlv_count++; 575 + /* Move to next sub TLV */ 576 + sub_tlv = (struct ice_cee_feat_tlv *) 577 + ((char *)sub_tlv + sizeof(sub_tlv->hdr.typelen) + 578 + sublen); 579 + } 580 + } 581 + 582 + /** 583 + * ice_parse_org_tlv 584 + * @tlv: Organization specific TLV 585 + * @dcbcfg: Local store to update ETS REC data 586 + * 587 + * Currently only IEEE 802.1Qaz TLV is supported, all others 588 + * will be returned 589 + */ 590 + static void 591 + ice_parse_org_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg) 592 + { 593 + u32 ouisubtype; 594 + u32 oui; 595 + 596 + ouisubtype = ntohl(tlv->ouisubtype); 597 + oui = ((ouisubtype & ICE_LLDP_TLV_OUI_M) >> ICE_LLDP_TLV_OUI_S); 598 + switch (oui) { 599 + case ICE_IEEE_8021QAZ_OUI: 600 + ice_parse_ieee_tlv(tlv, dcbcfg); 601 + break; 602 + case ICE_CEE_DCBX_OUI: 603 + ice_parse_cee_tlv(tlv, dcbcfg); 604 + break; 605 + default: 606 + break; 607 + } 608 + } 609 + 610 + /** 611 + * ice_lldp_to_dcb_cfg 612 + * @lldpmib: LLDPDU to be parsed 613 + * @dcbcfg: store for LLDPDU data 614 + * 615 + * Parse DCB configuration from the LLDPDU 616 + */ 617 + enum ice_status ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg) 618 + { 619 + struct ice_lldp_org_tlv *tlv; 620 + enum ice_status ret = 0; 621 + u16 offset = 0; 622 + u16 typelen; 623 + u16 type; 624 + u16 len; 625 + 626 + if (!lldpmib || !dcbcfg) 627 + return ICE_ERR_PARAM; 628 + 629 + /* set to the start of LLDPDU */ 630 + lldpmib += ETH_HLEN; 631 + tlv = (struct ice_lldp_org_tlv *)lldpmib; 632 + while (1) { 633 + typelen = ntohs(tlv->typelen); 634 + type = ((typelen & ICE_LLDP_TLV_TYPE_M) >> ICE_LLDP_TLV_TYPE_S); 635 + len = ((typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S); 636 + offset += sizeof(typelen) + len; 637 + 638 + /* END TLV or beyond LLDPDU size */ 639 + if (type == ICE_TLV_TYPE_END || offset > ICE_LLDPDU_SIZE) 640 + break; 641 + 642 + switch (type) { 643 + case ICE_TLV_TYPE_ORG: 644 + ice_parse_org_tlv(tlv, dcbcfg); 645 + break; 646 + default: 647 + break; 648 + } 649 + 650 + /* Move to next TLV */ 651 + tlv = (struct ice_lldp_org_tlv *) 652 + ((char *)tlv + sizeof(tlv->typelen) + len); 653 + } 654 + 655 + return ret; 656 + } 657 + 658 + /** 659 + * ice_aq_get_dcb_cfg 660 + * @hw: pointer to the HW struct 661 + * @mib_type: mib type for the query 662 + * @bridgetype: bridge type for the query (remote) 663 + * @dcbcfg: store for LLDPDU data 664 + * 665 + * Query DCB configuration from the firmware 666 + */ 667 + static enum ice_status 668 + ice_aq_get_dcb_cfg(struct ice_hw *hw, u8 mib_type, u8 bridgetype, 669 + struct ice_dcbx_cfg *dcbcfg) 670 + { 671 + enum ice_status ret; 672 + u8 *lldpmib; 673 + 674 + /* Allocate the LLDPDU */ 675 + lldpmib = devm_kzalloc(ice_hw_to_dev(hw), ICE_LLDPDU_SIZE, GFP_KERNEL); 676 + if (!lldpmib) 677 + return ICE_ERR_NO_MEMORY; 678 + 679 + ret = ice_aq_get_lldp_mib(hw, bridgetype, mib_type, (void *)lldpmib, 680 + ICE_LLDPDU_SIZE, NULL, NULL, NULL); 681 + 682 + if (!ret) 683 + /* Parse LLDP MIB to get DCB configuration */ 684 + ret = ice_lldp_to_dcb_cfg(lldpmib, dcbcfg); 685 + 686 + devm_kfree(ice_hw_to_dev(hw), lldpmib); 687 + 688 + return ret; 689 + } 690 + 691 + /** 692 + * ice_aq_start_stop_dcbx - Start/Stop DCBx service in FW 693 + * @hw: pointer to the HW struct 694 + * @start_dcbx_agent: True if DCBx Agent needs to be started 695 + * False if DCBx Agent needs to be stopped 696 + * @dcbx_agent_status: FW indicates back the DCBx agent status 697 + * True if DCBx Agent is active 698 + * False if DCBx Agent is stopped 699 + * @cd: pointer to command details structure or NULL 700 + * 701 + * Start/Stop the embedded dcbx Agent. In case that this wrapper function 702 + * returns ICE_SUCCESS, caller will need to check if FW returns back the same 703 + * value as stated in dcbx_agent_status, and react accordingly. (0x0A09) 704 + */ 705 + enum ice_status 706 + ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent, 707 + bool *dcbx_agent_status, struct ice_sq_cd *cd) 708 + { 709 + struct ice_aqc_lldp_stop_start_specific_agent *cmd; 710 + enum ice_status status; 711 + struct ice_aq_desc desc; 712 + u16 opcode; 713 + 714 + cmd = &desc.params.lldp_agent_ctrl; 715 + 716 + opcode = ice_aqc_opc_lldp_stop_start_specific_agent; 717 + 718 + ice_fill_dflt_direct_cmd_desc(&desc, opcode); 719 + 720 + if (start_dcbx_agent) 721 + cmd->command = ICE_AQC_START_STOP_AGENT_START_DCBX; 722 + 723 + status = ice_aq_send_cmd(hw, &desc, NULL, 0, cd); 724 + 725 + *dcbx_agent_status = false; 726 + 727 + if (!status && 728 + cmd->command == ICE_AQC_START_STOP_AGENT_START_DCBX) 729 + *dcbx_agent_status = true; 730 + 731 + return status; 732 + } 733 + 734 + /** 735 + * ice_aq_get_cee_dcb_cfg 736 + * @hw: pointer to the HW struct 737 + * @buff: response buffer that stores CEE operational configuration 738 + * @cd: pointer to command details structure or NULL 739 + * 740 + * Get CEE DCBX mode operational configuration from firmware (0x0A07) 741 + */ 742 + static enum ice_status 743 + ice_aq_get_cee_dcb_cfg(struct ice_hw *hw, 744 + struct ice_aqc_get_cee_dcb_cfg_resp *buff, 745 + struct ice_sq_cd *cd) 746 + { 747 + struct ice_aq_desc desc; 748 + 749 + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_get_cee_dcb_cfg); 750 + 751 + return ice_aq_send_cmd(hw, &desc, (void *)buff, sizeof(*buff), cd); 752 + } 753 + 754 + /** 755 + * ice_cee_to_dcb_cfg 756 + * @cee_cfg: pointer to CEE configuration struct 757 + * @dcbcfg: DCB configuration struct 758 + * 759 + * Convert CEE configuration from firmware to DCB configuration 760 + */ 761 + static void 762 + ice_cee_to_dcb_cfg(struct ice_aqc_get_cee_dcb_cfg_resp *cee_cfg, 763 + struct ice_dcbx_cfg *dcbcfg) 764 + { 765 + u32 status, tlv_status = le32_to_cpu(cee_cfg->tlv_status); 766 + u32 ice_aqc_cee_status_mask, ice_aqc_cee_status_shift; 767 + u16 app_prio = le16_to_cpu(cee_cfg->oper_app_prio); 768 + u8 i, err, sync, oper, app_index, ice_app_sel_type; 769 + u16 ice_aqc_cee_app_mask, ice_aqc_cee_app_shift; 770 + u16 ice_app_prot_id_type; 771 + 772 + /* CEE PG data to ETS config */ 773 + dcbcfg->etscfg.maxtcs = cee_cfg->oper_num_tc; 774 + 775 + /* Note that the FW creates the oper_prio_tc nibbles reversed 776 + * from those in the CEE Priority Group sub-TLV. 777 + */ 778 + for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) { 779 + dcbcfg->etscfg.prio_table[i * 2] = 780 + ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_0_M) >> 781 + ICE_CEE_PGID_PRIO_0_S); 782 + dcbcfg->etscfg.prio_table[i * 2 + 1] = 783 + ((cee_cfg->oper_prio_tc[i] & ICE_CEE_PGID_PRIO_1_M) >> 784 + ICE_CEE_PGID_PRIO_1_S); 785 + } 786 + 787 + ice_for_each_traffic_class(i) { 788 + dcbcfg->etscfg.tcbwtable[i] = cee_cfg->oper_tc_bw[i]; 789 + 790 + if (dcbcfg->etscfg.prio_table[i] == ICE_CEE_PGID_STRICT) { 791 + /* Map it to next empty TC */ 792 + dcbcfg->etscfg.prio_table[i] = cee_cfg->oper_num_tc - 1; 793 + dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_STRICT; 794 + } else { 795 + dcbcfg->etscfg.tsatable[i] = ICE_IEEE_TSA_ETS; 796 + } 797 + } 798 + 799 + /* CEE PFC data to ETS config */ 800 + dcbcfg->pfc.pfcena = cee_cfg->oper_pfc_en; 801 + dcbcfg->pfc.pfccap = ICE_MAX_TRAFFIC_CLASS; 802 + 803 + app_index = 0; 804 + for (i = 0; i < 3; i++) { 805 + if (i == 0) { 806 + /* FCoE APP */ 807 + ice_aqc_cee_status_mask = ICE_AQC_CEE_FCOE_STATUS_M; 808 + ice_aqc_cee_status_shift = ICE_AQC_CEE_FCOE_STATUS_S; 809 + ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FCOE_M; 810 + ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FCOE_S; 811 + ice_app_sel_type = ICE_APP_SEL_ETHTYPE; 812 + ice_app_prot_id_type = ICE_APP_PROT_ID_FCOE; 813 + } else if (i == 1) { 814 + /* iSCSI APP */ 815 + ice_aqc_cee_status_mask = ICE_AQC_CEE_ISCSI_STATUS_M; 816 + ice_aqc_cee_status_shift = ICE_AQC_CEE_ISCSI_STATUS_S; 817 + ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_ISCSI_M; 818 + ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_ISCSI_S; 819 + ice_app_sel_type = ICE_APP_SEL_TCPIP; 820 + ice_app_prot_id_type = ICE_APP_PROT_ID_ISCSI; 821 + } else { 822 + /* FIP APP */ 823 + ice_aqc_cee_status_mask = ICE_AQC_CEE_FIP_STATUS_M; 824 + ice_aqc_cee_status_shift = ICE_AQC_CEE_FIP_STATUS_S; 825 + ice_aqc_cee_app_mask = ICE_AQC_CEE_APP_FIP_M; 826 + ice_aqc_cee_app_shift = ICE_AQC_CEE_APP_FIP_S; 827 + ice_app_sel_type = ICE_APP_SEL_ETHTYPE; 828 + ice_app_prot_id_type = ICE_APP_PROT_ID_FIP; 829 + } 830 + 831 + status = (tlv_status & ice_aqc_cee_status_mask) >> 832 + ice_aqc_cee_status_shift; 833 + err = (status & ICE_TLV_STATUS_ERR) ? 1 : 0; 834 + sync = (status & ICE_TLV_STATUS_SYNC) ? 1 : 0; 835 + oper = (status & ICE_TLV_STATUS_OPER) ? 1 : 0; 836 + /* Add FCoE/iSCSI/FIP APP if Error is False and 837 + * Oper/Sync is True 838 + */ 839 + if (!err && sync && oper) { 840 + dcbcfg->app[app_index].priority = 841 + (app_prio & ice_aqc_cee_app_mask) >> 842 + ice_aqc_cee_app_shift; 843 + dcbcfg->app[app_index].selector = ice_app_sel_type; 844 + dcbcfg->app[app_index].prot_id = ice_app_prot_id_type; 845 + app_index++; 846 + } 847 + } 848 + 849 + dcbcfg->numapps = app_index; 850 + } 851 + 852 + /** 853 + * ice_get_ieee_dcb_cfg 854 + * @pi: port information structure 855 + * @dcbx_mode: mode of DCBX (IEEE or CEE) 856 + * 857 + * Get IEEE or CEE mode DCB configuration from the Firmware 858 + */ 859 + static enum ice_status 860 + ice_get_ieee_or_cee_dcb_cfg(struct ice_port_info *pi, u8 dcbx_mode) 861 + { 862 + struct ice_dcbx_cfg *dcbx_cfg = NULL; 863 + enum ice_status ret; 864 + 865 + if (!pi) 866 + return ICE_ERR_PARAM; 867 + 868 + if (dcbx_mode == ICE_DCBX_MODE_IEEE) 869 + dcbx_cfg = &pi->local_dcbx_cfg; 870 + else if (dcbx_mode == ICE_DCBX_MODE_CEE) 871 + dcbx_cfg = &pi->desired_dcbx_cfg; 872 + 873 + /* Get Local DCB Config in case of ICE_DCBX_MODE_IEEE 874 + * or get CEE DCB Desired Config in case of ICE_DCBX_MODE_CEE 875 + */ 876 + ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_LOCAL, 877 + ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg); 878 + if (ret) 879 + goto out; 880 + 881 + /* Get Remote DCB Config */ 882 + dcbx_cfg = &pi->remote_dcbx_cfg; 883 + ret = ice_aq_get_dcb_cfg(pi->hw, ICE_AQ_LLDP_MIB_REMOTE, 884 + ICE_AQ_LLDP_BRID_TYPE_NEAREST_BRID, dcbx_cfg); 885 + /* Don't treat ENOENT as an error for Remote MIBs */ 886 + if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT) 887 + ret = 0; 888 + 889 + out: 890 + return ret; 891 + } 892 + 893 + /** 894 + * ice_get_dcb_cfg 895 + * @pi: port information structure 896 + * 897 + * Get DCB configuration from the Firmware 898 + */ 899 + enum ice_status ice_get_dcb_cfg(struct ice_port_info *pi) 900 + { 901 + struct ice_aqc_get_cee_dcb_cfg_resp cee_cfg; 902 + struct ice_dcbx_cfg *dcbx_cfg; 903 + enum ice_status ret; 904 + 905 + if (!pi) 906 + return ICE_ERR_PARAM; 907 + 908 + ret = ice_aq_get_cee_dcb_cfg(pi->hw, &cee_cfg, NULL); 909 + if (!ret) { 910 + /* CEE mode */ 911 + dcbx_cfg = &pi->local_dcbx_cfg; 912 + dcbx_cfg->dcbx_mode = ICE_DCBX_MODE_CEE; 913 + dcbx_cfg->tlv_status = le32_to_cpu(cee_cfg.tlv_status); 914 + ice_cee_to_dcb_cfg(&cee_cfg, dcbx_cfg); 915 + ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_CEE); 916 + } else if (pi->hw->adminq.sq_last_status == ICE_AQ_RC_ENOENT) { 917 + /* CEE mode not enabled try querying IEEE data */ 918 + dcbx_cfg = &pi->local_dcbx_cfg; 919 + dcbx_cfg->dcbx_mode = ICE_DCBX_MODE_IEEE; 920 + ret = ice_get_ieee_or_cee_dcb_cfg(pi, ICE_DCBX_MODE_IEEE); 921 + } 922 + 923 + return ret; 924 + } 925 + 926 + /** 927 + * ice_init_dcb 928 + * @hw: pointer to the HW struct 929 + * 930 + * Update DCB configuration from the Firmware 931 + */ 932 + enum ice_status ice_init_dcb(struct ice_hw *hw) 933 + { 934 + struct ice_port_info *pi = hw->port_info; 935 + enum ice_status ret = 0; 936 + 937 + if (!hw->func_caps.common_cap.dcb) 938 + return ICE_ERR_NOT_SUPPORTED; 939 + 940 + pi->is_sw_lldp = true; 941 + 942 + /* Get DCBX status */ 943 + pi->dcbx_status = ice_get_dcbx_status(hw); 944 + 945 + if (pi->dcbx_status == ICE_DCBX_STATUS_DONE || 946 + pi->dcbx_status == ICE_DCBX_STATUS_IN_PROGRESS) { 947 + /* Get current DCBX configuration */ 948 + ret = ice_get_dcb_cfg(pi); 949 + pi->is_sw_lldp = (hw->adminq.sq_last_status == ICE_AQ_RC_EPERM); 950 + if (ret) 951 + return ret; 952 + } else if (pi->dcbx_status == ICE_DCBX_STATUS_DIS) { 953 + return ICE_ERR_NOT_READY; 954 + } 955 + 956 + /* Configure the LLDP MIB change event */ 957 + ret = ice_aq_cfg_lldp_mib_change(hw, true, NULL); 958 + if (!ret) 959 + pi->is_sw_lldp = false; 960 + 961 + return ret; 962 + } 963 + 964 + /** 965 + * ice_add_ieee_ets_common_tlv 966 + * @buf: Data buffer to be populated with ice_dcb_ets_cfg data 967 + * @ets_cfg: Container for ice_dcb_ets_cfg data 968 + * 969 + * Populate the TLV buffer with ice_dcb_ets_cfg data 970 + */ 971 + static void 972 + ice_add_ieee_ets_common_tlv(u8 *buf, struct ice_dcb_ets_cfg *ets_cfg) 973 + { 974 + u8 priority0, priority1; 975 + u8 offset = 0; 976 + int i; 977 + 978 + /* Priority Assignment Table (4 octets) 979 + * Octets:| 1 | 2 | 3 | 4 | 980 + * ----------------------------------------- 981 + * |pri0|pri1|pri2|pri3|pri4|pri5|pri6|pri7| 982 + * ----------------------------------------- 983 + * Bits:|7 4|3 0|7 4|3 0|7 4|3 0|7 4|3 0| 984 + * ----------------------------------------- 985 + */ 986 + for (i = 0; i < ICE_MAX_TRAFFIC_CLASS / 2; i++) { 987 + priority0 = ets_cfg->prio_table[i * 2] & 0xF; 988 + priority1 = ets_cfg->prio_table[i * 2 + 1] & 0xF; 989 + buf[offset] = (priority0 << ICE_IEEE_ETS_PRIO_1_S) | priority1; 990 + offset++; 991 + } 992 + 993 + /* TC Bandwidth Table (8 octets) 994 + * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 995 + * --------------------------------- 996 + * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7| 997 + * --------------------------------- 998 + * 999 + * TSA Assignment Table (8 octets) 1000 + * Octets:| 1 | 2 | 3 | 4 | 5 | 6 | 7 | 8 | 1001 + * --------------------------------- 1002 + * |tc0|tc1|tc2|tc3|tc4|tc5|tc6|tc7| 1003 + * --------------------------------- 1004 + */ 1005 + ice_for_each_traffic_class(i) { 1006 + buf[offset] = ets_cfg->tcbwtable[i]; 1007 + buf[ICE_MAX_TRAFFIC_CLASS + offset] = ets_cfg->tsatable[i]; 1008 + offset++; 1009 + } 1010 + } 1011 + 1012 + /** 1013 + * ice_add_ieee_ets_tlv - Prepare ETS TLV in IEEE format 1014 + * @tlv: Fill the ETS config data in IEEE format 1015 + * @dcbcfg: Local store which holds the DCB Config 1016 + * 1017 + * Prepare IEEE 802.1Qaz ETS CFG TLV 1018 + */ 1019 + static void 1020 + ice_add_ieee_ets_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg) 1021 + { 1022 + struct ice_dcb_ets_cfg *etscfg; 1023 + u8 *buf = tlv->tlvinfo; 1024 + u8 maxtcwilling = 0; 1025 + u32 ouisubtype; 1026 + u16 typelen; 1027 + 1028 + typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) | 1029 + ICE_IEEE_ETS_TLV_LEN); 1030 + tlv->typelen = htons(typelen); 1031 + 1032 + ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) | 1033 + ICE_IEEE_SUBTYPE_ETS_CFG); 1034 + tlv->ouisubtype = htonl(ouisubtype); 1035 + 1036 + /* First Octet post subtype 1037 + * -------------------------- 1038 + * |will-|CBS | Re- | Max | 1039 + * |ing | |served| TCs | 1040 + * -------------------------- 1041 + * |1bit | 1bit|3 bits|3bits| 1042 + */ 1043 + etscfg = &dcbcfg->etscfg; 1044 + if (etscfg->willing) 1045 + maxtcwilling = BIT(ICE_IEEE_ETS_WILLING_S); 1046 + maxtcwilling |= etscfg->maxtcs & ICE_IEEE_ETS_MAXTC_M; 1047 + buf[0] = maxtcwilling; 1048 + 1049 + /* Begin adding at Priority Assignment Table (offset 1 in buf) */ 1050 + ice_add_ieee_ets_common_tlv(&buf[1], etscfg); 1051 + } 1052 + 1053 + /** 1054 + * ice_add_ieee_etsrec_tlv - Prepare ETS Recommended TLV in IEEE format 1055 + * @tlv: Fill ETS Recommended TLV in IEEE format 1056 + * @dcbcfg: Local store which holds the DCB Config 1057 + * 1058 + * Prepare IEEE 802.1Qaz ETS REC TLV 1059 + */ 1060 + static void 1061 + ice_add_ieee_etsrec_tlv(struct ice_lldp_org_tlv *tlv, 1062 + struct ice_dcbx_cfg *dcbcfg) 1063 + { 1064 + struct ice_dcb_ets_cfg *etsrec; 1065 + u8 *buf = tlv->tlvinfo; 1066 + u32 ouisubtype; 1067 + u16 typelen; 1068 + 1069 + typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) | 1070 + ICE_IEEE_ETS_TLV_LEN); 1071 + tlv->typelen = htons(typelen); 1072 + 1073 + ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) | 1074 + ICE_IEEE_SUBTYPE_ETS_REC); 1075 + tlv->ouisubtype = htonl(ouisubtype); 1076 + 1077 + etsrec = &dcbcfg->etsrec; 1078 + 1079 + /* First Octet is reserved */ 1080 + /* Begin adding at Priority Assignment Table (offset 1 in buf) */ 1081 + ice_add_ieee_ets_common_tlv(&buf[1], etsrec); 1082 + } 1083 + 1084 + /** 1085 + * ice_add_ieee_pfc_tlv - Prepare PFC TLV in IEEE format 1086 + * @tlv: Fill PFC TLV in IEEE format 1087 + * @dcbcfg: Local store which holds the PFC CFG data 1088 + * 1089 + * Prepare IEEE 802.1Qaz PFC CFG TLV 1090 + */ 1091 + static void 1092 + ice_add_ieee_pfc_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg) 1093 + { 1094 + u8 *buf = tlv->tlvinfo; 1095 + u32 ouisubtype; 1096 + u16 typelen; 1097 + 1098 + typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) | 1099 + ICE_IEEE_PFC_TLV_LEN); 1100 + tlv->typelen = htons(typelen); 1101 + 1102 + ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) | 1103 + ICE_IEEE_SUBTYPE_PFC_CFG); 1104 + tlv->ouisubtype = htonl(ouisubtype); 1105 + 1106 + /* ---------------------------------------- 1107 + * |will-|MBC | Re- | PFC | PFC Enable | 1108 + * |ing | |served| cap | | 1109 + * ----------------------------------------- 1110 + * |1bit | 1bit|2 bits|4bits| 1 octet | 1111 + */ 1112 + if (dcbcfg->pfc.willing) 1113 + buf[0] = BIT(ICE_IEEE_PFC_WILLING_S); 1114 + 1115 + if (dcbcfg->pfc.mbc) 1116 + buf[0] |= BIT(ICE_IEEE_PFC_MBC_S); 1117 + 1118 + buf[0] |= dcbcfg->pfc.pfccap & 0xF; 1119 + buf[1] = dcbcfg->pfc.pfcena; 1120 + } 1121 + 1122 + /** 1123 + * ice_add_ieee_app_pri_tlv - Prepare APP TLV in IEEE format 1124 + * @tlv: Fill APP TLV in IEEE format 1125 + * @dcbcfg: Local store which holds the APP CFG data 1126 + * 1127 + * Prepare IEEE 802.1Qaz APP CFG TLV 1128 + */ 1129 + static void 1130 + ice_add_ieee_app_pri_tlv(struct ice_lldp_org_tlv *tlv, 1131 + struct ice_dcbx_cfg *dcbcfg) 1132 + { 1133 + u16 typelen, len, offset = 0; 1134 + u8 priority, selector, i = 0; 1135 + u8 *buf = tlv->tlvinfo; 1136 + u32 ouisubtype; 1137 + 1138 + /* No APP TLVs then just return */ 1139 + if (dcbcfg->numapps == 0) 1140 + return; 1141 + ouisubtype = ((ICE_IEEE_8021QAZ_OUI << ICE_LLDP_TLV_OUI_S) | 1142 + ICE_IEEE_SUBTYPE_APP_PRI); 1143 + tlv->ouisubtype = htonl(ouisubtype); 1144 + 1145 + /* Move offset to App Priority Table */ 1146 + offset++; 1147 + /* Application Priority Table (3 octets) 1148 + * Octets:| 1 | 2 | 3 | 1149 + * ----------------------------------------- 1150 + * |Priority|Rsrvd| Sel | Protocol ID | 1151 + * ----------------------------------------- 1152 + * Bits:|23 21|20 19|18 16|15 0| 1153 + * ----------------------------------------- 1154 + */ 1155 + while (i < dcbcfg->numapps) { 1156 + priority = dcbcfg->app[i].priority & 0x7; 1157 + selector = dcbcfg->app[i].selector & 0x7; 1158 + buf[offset] = (priority << ICE_IEEE_APP_PRIO_S) | selector; 1159 + buf[offset + 1] = (dcbcfg->app[i].prot_id >> 0x8) & 0xFF; 1160 + buf[offset + 2] = dcbcfg->app[i].prot_id & 0xFF; 1161 + /* Move to next app */ 1162 + offset += 3; 1163 + i++; 1164 + if (i >= ICE_DCBX_MAX_APPS) 1165 + break; 1166 + } 1167 + /* len includes size of ouisubtype + 1 reserved + 3*numapps */ 1168 + len = sizeof(tlv->ouisubtype) + 1 + (i * 3); 1169 + typelen = ((ICE_TLV_TYPE_ORG << ICE_LLDP_TLV_TYPE_S) | (len & 0x1FF)); 1170 + tlv->typelen = htons(typelen); 1171 + } 1172 + 1173 + /** 1174 + * ice_add_dcb_tlv - Add all IEEE TLVs 1175 + * @tlv: Fill TLV data in IEEE format 1176 + * @dcbcfg: Local store which holds the DCB Config 1177 + * @tlvid: Type of IEEE TLV 1178 + * 1179 + * Add tlv information 1180 + */ 1181 + static void 1182 + ice_add_dcb_tlv(struct ice_lldp_org_tlv *tlv, struct ice_dcbx_cfg *dcbcfg, 1183 + u16 tlvid) 1184 + { 1185 + switch (tlvid) { 1186 + case ICE_IEEE_TLV_ID_ETS_CFG: 1187 + ice_add_ieee_ets_tlv(tlv, dcbcfg); 1188 + break; 1189 + case ICE_IEEE_TLV_ID_ETS_REC: 1190 + ice_add_ieee_etsrec_tlv(tlv, dcbcfg); 1191 + break; 1192 + case ICE_IEEE_TLV_ID_PFC_CFG: 1193 + ice_add_ieee_pfc_tlv(tlv, dcbcfg); 1194 + break; 1195 + case ICE_IEEE_TLV_ID_APP_PRI: 1196 + ice_add_ieee_app_pri_tlv(tlv, dcbcfg); 1197 + break; 1198 + default: 1199 + break; 1200 + } 1201 + } 1202 + 1203 + /** 1204 + * ice_dcb_cfg_to_lldp - Convert DCB configuration to MIB format 1205 + * @lldpmib: pointer to the HW struct 1206 + * @miblen: length of LLDP MIB 1207 + * @dcbcfg: Local store which holds the DCB Config 1208 + * 1209 + * Convert the DCB configuration to MIB format 1210 + */ 1211 + static void 1212 + ice_dcb_cfg_to_lldp(u8 *lldpmib, u16 *miblen, struct ice_dcbx_cfg *dcbcfg) 1213 + { 1214 + u16 len, offset = 0, tlvid = ICE_TLV_ID_START; 1215 + struct ice_lldp_org_tlv *tlv; 1216 + u16 typelen; 1217 + 1218 + tlv = (struct ice_lldp_org_tlv *)lldpmib; 1219 + while (1) { 1220 + ice_add_dcb_tlv(tlv, dcbcfg, tlvid++); 1221 + typelen = ntohs(tlv->typelen); 1222 + len = (typelen & ICE_LLDP_TLV_LEN_M) >> ICE_LLDP_TLV_LEN_S; 1223 + if (len) 1224 + offset += len + 2; 1225 + /* END TLV or beyond LLDPDU size */ 1226 + if (tlvid >= ICE_TLV_ID_END_OF_LLDPPDU || 1227 + offset > ICE_LLDPDU_SIZE) 1228 + break; 1229 + /* Move to next TLV */ 1230 + if (len) 1231 + tlv = (struct ice_lldp_org_tlv *) 1232 + ((char *)tlv + sizeof(tlv->typelen) + len); 1233 + } 1234 + *miblen = offset; 1235 + } 1236 + 1237 + /** 1238 + * ice_set_dcb_cfg - Set the local LLDP MIB to FW 1239 + * @pi: port information structure 1240 + * 1241 + * Set DCB configuration to the Firmware 1242 + */ 1243 + enum ice_status ice_set_dcb_cfg(struct ice_port_info *pi) 1244 + { 1245 + u8 mib_type, *lldpmib = NULL; 1246 + struct ice_dcbx_cfg *dcbcfg; 1247 + enum ice_status ret; 1248 + struct ice_hw *hw; 1249 + u16 miblen; 1250 + 1251 + if (!pi) 1252 + return ICE_ERR_PARAM; 1253 + 1254 + hw = pi->hw; 1255 + 1256 + /* update the HW local config */ 1257 + dcbcfg = &pi->local_dcbx_cfg; 1258 + /* Allocate the LLDPDU */ 1259 + lldpmib = devm_kzalloc(ice_hw_to_dev(hw), ICE_LLDPDU_SIZE, GFP_KERNEL); 1260 + if (!lldpmib) 1261 + return ICE_ERR_NO_MEMORY; 1262 + 1263 + mib_type = SET_LOCAL_MIB_TYPE_LOCAL_MIB; 1264 + if (dcbcfg->app_mode == ICE_DCBX_APPS_NON_WILLING) 1265 + mib_type |= SET_LOCAL_MIB_TYPE_CEE_NON_WILLING; 1266 + 1267 + ice_dcb_cfg_to_lldp(lldpmib, &miblen, dcbcfg); 1268 + ret = ice_aq_set_lldp_mib(hw, mib_type, (void *)lldpmib, miblen, 1269 + NULL); 1270 + 1271 + devm_kfree(ice_hw_to_dev(hw), lldpmib); 1272 + 1273 + return ret; 1274 + } 1275 + 1276 + /** 1277 + * ice_aq_query_port_ets - query port ets configuration 1278 + * @pi: port information structure 1279 + * @buf: pointer to buffer 1280 + * @buf_size: buffer size in bytes 1281 + * @cd: pointer to command details structure or NULL 1282 + * 1283 + * query current port ets configuration 1284 + */ 1285 + static enum ice_status 1286 + ice_aq_query_port_ets(struct ice_port_info *pi, 1287 + struct ice_aqc_port_ets_elem *buf, u16 buf_size, 1288 + struct ice_sq_cd *cd) 1289 + { 1290 + struct ice_aqc_query_port_ets *cmd; 1291 + struct ice_aq_desc desc; 1292 + enum ice_status status; 1293 + 1294 + if (!pi) 1295 + return ICE_ERR_PARAM; 1296 + cmd = &desc.params.port_ets; 1297 + ice_fill_dflt_direct_cmd_desc(&desc, ice_aqc_opc_query_port_ets); 1298 + cmd->port_teid = pi->root->info.node_teid; 1299 + 1300 + status = ice_aq_send_cmd(pi->hw, &desc, buf, buf_size, cd); 1301 + return status; 1302 + } 1303 + 1304 + /** 1305 + * ice_update_port_tc_tree_cfg - update TC tree configuration 1306 + * @pi: port information structure 1307 + * @buf: pointer to buffer 1308 + * 1309 + * update the SW DB with the new TC changes 1310 + */ 1311 + static enum ice_status 1312 + ice_update_port_tc_tree_cfg(struct ice_port_info *pi, 1313 + struct ice_aqc_port_ets_elem *buf) 1314 + { 1315 + struct ice_sched_node *node, *tc_node; 1316 + struct ice_aqc_get_elem elem; 1317 + enum ice_status status = 0; 1318 + u32 teid1, teid2; 1319 + u8 i, j; 1320 + 1321 + if (!pi) 1322 + return ICE_ERR_PARAM; 1323 + /* suspend the missing TC nodes */ 1324 + for (i = 0; i < pi->root->num_children; i++) { 1325 + teid1 = le32_to_cpu(pi->root->children[i]->info.node_teid); 1326 + ice_for_each_traffic_class(j) { 1327 + teid2 = le32_to_cpu(buf->tc_node_teid[j]); 1328 + if (teid1 == teid2) 1329 + break; 1330 + } 1331 + if (j < ICE_MAX_TRAFFIC_CLASS) 1332 + continue; 1333 + /* TC is missing */ 1334 + pi->root->children[i]->in_use = false; 1335 + } 1336 + /* add the new TC nodes */ 1337 + ice_for_each_traffic_class(j) { 1338 + teid2 = le32_to_cpu(buf->tc_node_teid[j]); 1339 + if (teid2 == ICE_INVAL_TEID) 1340 + continue; 1341 + /* Is it already present in the tree ? */ 1342 + for (i = 0; i < pi->root->num_children; i++) { 1343 + tc_node = pi->root->children[i]; 1344 + if (!tc_node) 1345 + continue; 1346 + teid1 = le32_to_cpu(tc_node->info.node_teid); 1347 + if (teid1 == teid2) { 1348 + tc_node->tc_num = j; 1349 + tc_node->in_use = true; 1350 + break; 1351 + } 1352 + } 1353 + if (i < pi->root->num_children) 1354 + continue; 1355 + /* new TC */ 1356 + status = ice_sched_query_elem(pi->hw, teid2, &elem); 1357 + if (!status) 1358 + status = ice_sched_add_node(pi, 1, &elem.generic[0]); 1359 + if (status) 1360 + break; 1361 + /* update the TC number */ 1362 + node = ice_sched_find_node_by_teid(pi->root, teid2); 1363 + if (node) 1364 + node->tc_num = j; 1365 + } 1366 + return status; 1367 + } 1368 + 1369 + /** 1370 + * ice_query_port_ets - query port ets configuration 1371 + * @pi: port information structure 1372 + * @buf: pointer to buffer 1373 + * @buf_size: buffer size in bytes 1374 + * @cd: pointer to command details structure or NULL 1375 + * 1376 + * query current port ets configuration and update the 1377 + * SW DB with the TC changes 1378 + */ 1379 + enum ice_status 1380 + ice_query_port_ets(struct ice_port_info *pi, 1381 + struct ice_aqc_port_ets_elem *buf, u16 buf_size, 1382 + struct ice_sq_cd *cd) 1383 + { 1384 + enum ice_status status; 1385 + 1386 + mutex_lock(&pi->sched_lock); 1387 + status = ice_aq_query_port_ets(pi, buf, buf_size, cd); 1388 + if (!status) 1389 + status = ice_update_port_tc_tree_cfg(pi, buf); 1390 + mutex_unlock(&pi->sched_lock); 1391 + return status; 1392 + }
+179
drivers/net/ethernet/intel/ice/ice_dcb.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* Copyright (c) 2019, Intel Corporation. */ 3 + 4 + #ifndef _ICE_DCB_H_ 5 + #define _ICE_DCB_H_ 6 + 7 + #include "ice_type.h" 8 + 9 + #define ICE_DCBX_STATUS_NOT_STARTED 0 10 + #define ICE_DCBX_STATUS_IN_PROGRESS 1 11 + #define ICE_DCBX_STATUS_DONE 2 12 + #define ICE_DCBX_STATUS_DIS 7 13 + 14 + #define ICE_TLV_TYPE_END 0 15 + #define ICE_TLV_TYPE_ORG 127 16 + 17 + #define ICE_IEEE_8021QAZ_OUI 0x0080C2 18 + #define ICE_IEEE_SUBTYPE_ETS_CFG 9 19 + #define ICE_IEEE_SUBTYPE_ETS_REC 10 20 + #define ICE_IEEE_SUBTYPE_PFC_CFG 11 21 + #define ICE_IEEE_SUBTYPE_APP_PRI 12 22 + 23 + #define ICE_CEE_DCBX_OUI 0x001B21 24 + #define ICE_CEE_DCBX_TYPE 2 25 + #define ICE_CEE_SUBTYPE_PG_CFG 2 26 + #define ICE_CEE_SUBTYPE_PFC_CFG 3 27 + #define ICE_CEE_SUBTYPE_APP_PRI 4 28 + #define ICE_CEE_MAX_FEAT_TYPE 3 29 + /* Defines for LLDP TLV header */ 30 + #define ICE_LLDP_TLV_LEN_S 0 31 + #define ICE_LLDP_TLV_LEN_M (0x01FF << ICE_LLDP_TLV_LEN_S) 32 + #define ICE_LLDP_TLV_TYPE_S 9 33 + #define ICE_LLDP_TLV_TYPE_M (0x7F << ICE_LLDP_TLV_TYPE_S) 34 + #define ICE_LLDP_TLV_SUBTYPE_S 0 35 + #define ICE_LLDP_TLV_SUBTYPE_M (0xFF << ICE_LLDP_TLV_SUBTYPE_S) 36 + #define ICE_LLDP_TLV_OUI_S 8 37 + #define ICE_LLDP_TLV_OUI_M (0xFFFFFFUL << ICE_LLDP_TLV_OUI_S) 38 + 39 + /* Defines for IEEE ETS TLV */ 40 + #define ICE_IEEE_ETS_MAXTC_S 0 41 + #define ICE_IEEE_ETS_MAXTC_M (0x7 << ICE_IEEE_ETS_MAXTC_S) 42 + #define ICE_IEEE_ETS_CBS_S 6 43 + #define ICE_IEEE_ETS_CBS_M BIT(ICE_IEEE_ETS_CBS_S) 44 + #define ICE_IEEE_ETS_WILLING_S 7 45 + #define ICE_IEEE_ETS_WILLING_M BIT(ICE_IEEE_ETS_WILLING_S) 46 + #define ICE_IEEE_ETS_PRIO_0_S 0 47 + #define ICE_IEEE_ETS_PRIO_0_M (0x7 << ICE_IEEE_ETS_PRIO_0_S) 48 + #define ICE_IEEE_ETS_PRIO_1_S 4 49 + #define ICE_IEEE_ETS_PRIO_1_M (0x7 << ICE_IEEE_ETS_PRIO_1_S) 50 + #define ICE_CEE_PGID_PRIO_0_S 0 51 + #define ICE_CEE_PGID_PRIO_0_M (0xF << ICE_CEE_PGID_PRIO_0_S) 52 + #define ICE_CEE_PGID_PRIO_1_S 4 53 + #define ICE_CEE_PGID_PRIO_1_M (0xF << ICE_CEE_PGID_PRIO_1_S) 54 + #define ICE_CEE_PGID_STRICT 15 55 + 56 + /* Defines for IEEE TSA types */ 57 + #define ICE_IEEE_TSA_STRICT 0 58 + #define ICE_IEEE_TSA_ETS 2 59 + 60 + /* Defines for IEEE PFC TLV */ 61 + #define ICE_IEEE_PFC_CAP_S 0 62 + #define ICE_IEEE_PFC_CAP_M (0xF << ICE_IEEE_PFC_CAP_S) 63 + #define ICE_IEEE_PFC_MBC_S 6 64 + #define ICE_IEEE_PFC_MBC_M BIT(ICE_IEEE_PFC_MBC_S) 65 + #define ICE_IEEE_PFC_WILLING_S 7 66 + #define ICE_IEEE_PFC_WILLING_M BIT(ICE_IEEE_PFC_WILLING_S) 67 + 68 + /* Defines for IEEE APP TLV */ 69 + #define ICE_IEEE_APP_SEL_S 0 70 + #define ICE_IEEE_APP_SEL_M (0x7 << ICE_IEEE_APP_SEL_S) 71 + #define ICE_IEEE_APP_PRIO_S 5 72 + #define ICE_IEEE_APP_PRIO_M (0x7 << ICE_IEEE_APP_PRIO_S) 73 + 74 + /* TLV definitions for preparing MIB */ 75 + #define ICE_IEEE_TLV_ID_ETS_CFG 3 76 + #define ICE_IEEE_TLV_ID_ETS_REC 4 77 + #define ICE_IEEE_TLV_ID_PFC_CFG 5 78 + #define ICE_IEEE_TLV_ID_APP_PRI 6 79 + #define ICE_TLV_ID_END_OF_LLDPPDU 7 80 + #define ICE_TLV_ID_START ICE_IEEE_TLV_ID_ETS_CFG 81 + 82 + #define ICE_IEEE_ETS_TLV_LEN 25 83 + #define ICE_IEEE_PFC_TLV_LEN 6 84 + #define ICE_IEEE_APP_TLV_LEN 11 85 + 86 + /* IEEE 802.1AB LLDP Organization specific TLV */ 87 + struct ice_lldp_org_tlv { 88 + __be16 typelen; 89 + __be32 ouisubtype; 90 + u8 tlvinfo[1]; 91 + } __packed; 92 + 93 + struct ice_cee_tlv_hdr { 94 + __be16 typelen; 95 + u8 operver; 96 + u8 maxver; 97 + }; 98 + 99 + struct ice_cee_ctrl_tlv { 100 + struct ice_cee_tlv_hdr hdr; 101 + __be32 seqno; 102 + __be32 ackno; 103 + }; 104 + 105 + struct ice_cee_feat_tlv { 106 + struct ice_cee_tlv_hdr hdr; 107 + u8 en_will_err; /* Bits: |En|Will|Err|Reserved(5)| */ 108 + #define ICE_CEE_FEAT_TLV_ENA_M 0x80 109 + #define ICE_CEE_FEAT_TLV_WILLING_M 0x40 110 + #define ICE_CEE_FEAT_TLV_ERR_M 0x20 111 + u8 subtype; 112 + u8 tlvinfo[1]; 113 + }; 114 + 115 + struct ice_cee_app_prio { 116 + __be16 protocol; 117 + u8 upper_oui_sel; /* Bits: |Upper OUI(6)|Selector(2)| */ 118 + #define ICE_CEE_APP_SELECTOR_M 0x03 119 + __be16 lower_oui; 120 + u8 prio_map; 121 + } __packed; 122 + 123 + u8 ice_get_dcbx_status(struct ice_hw *hw); 124 + enum ice_status ice_lldp_to_dcb_cfg(u8 *lldpmib, struct ice_dcbx_cfg *dcbcfg); 125 + enum ice_status ice_get_dcb_cfg(struct ice_port_info *pi); 126 + enum ice_status ice_set_dcb_cfg(struct ice_port_info *pi); 127 + enum ice_status ice_init_dcb(struct ice_hw *hw); 128 + enum ice_status 129 + ice_query_port_ets(struct ice_port_info *pi, 130 + struct ice_aqc_port_ets_elem *buf, u16 buf_size, 131 + struct ice_sq_cd *cmd_details); 132 + #ifdef CONFIG_DCB 133 + enum ice_status 134 + ice_aq_stop_lldp(struct ice_hw *hw, bool shutdown_lldp_agent, 135 + struct ice_sq_cd *cd); 136 + enum ice_status ice_aq_start_lldp(struct ice_hw *hw, struct ice_sq_cd *cd); 137 + enum ice_status 138 + ice_aq_start_stop_dcbx(struct ice_hw *hw, bool start_dcbx_agent, 139 + bool *dcbx_agent_status, struct ice_sq_cd *cd); 140 + enum ice_status 141 + ice_aq_cfg_lldp_mib_change(struct ice_hw *hw, bool ena_update, 142 + struct ice_sq_cd *cd); 143 + #else /* CONFIG_DCB */ 144 + static inline enum ice_status 145 + ice_aq_stop_lldp(struct ice_hw __always_unused *hw, 146 + bool __always_unused shutdown_lldp_agent, 147 + struct ice_sq_cd __always_unused *cd) 148 + { 149 + return 0; 150 + } 151 + 152 + static inline enum ice_status 153 + ice_aq_start_lldp(struct ice_hw __always_unused *hw, 154 + struct ice_sq_cd __always_unused *cd) 155 + { 156 + return 0; 157 + } 158 + 159 + static inline enum ice_status 160 + ice_aq_start_stop_dcbx(struct ice_hw __always_unused *hw, 161 + bool __always_unused start_dcbx_agent, 162 + bool *dcbx_agent_status, 163 + struct ice_sq_cd __always_unused *cd) 164 + { 165 + *dcbx_agent_status = false; 166 + 167 + return 0; 168 + } 169 + 170 + static inline enum ice_status 171 + ice_aq_cfg_lldp_mib_change(struct ice_hw __always_unused *hw, 172 + bool __always_unused ena_update, 173 + struct ice_sq_cd __always_unused *cd) 174 + { 175 + return 0; 176 + } 177 + 178 + #endif /* CONFIG_DCB */ 179 + #endif /* _ICE_DCB_H_ */
+551
drivers/net/ethernet/intel/ice/ice_dcb_lib.c
··· 1 + // SPDX-License-Identifier: GPL-2.0 2 + /* Copyright (c) 2019, Intel Corporation. */ 3 + 4 + #include "ice_dcb_lib.h" 5 + 6 + /** 7 + * ice_dcb_get_ena_tc - return bitmap of enabled TCs 8 + * @dcbcfg: DCB config to evaluate for enabled TCs 9 + */ 10 + u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg) 11 + { 12 + u8 i, num_tc, ena_tc = 1; 13 + 14 + num_tc = ice_dcb_get_num_tc(dcbcfg); 15 + 16 + for (i = 0; i < num_tc; i++) 17 + ena_tc |= BIT(i); 18 + 19 + return ena_tc; 20 + } 21 + 22 + /** 23 + * ice_dcb_get_num_tc - Get the number of TCs from DCBX config 24 + * @dcbcfg: config to retrieve number of TCs from 25 + */ 26 + u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg) 27 + { 28 + bool tc_unused = false; 29 + u8 num_tc = 0; 30 + u8 ret = 0; 31 + int i; 32 + 33 + /* Scan the ETS Config Priority Table to find traffic classes 34 + * enabled and create a bitmask of enabled TCs 35 + */ 36 + for (i = 0; i < CEE_DCBX_MAX_PRIO; i++) 37 + num_tc |= BIT(dcbcfg->etscfg.prio_table[i]); 38 + 39 + /* Scan bitmask for contiguous TCs starting with TC0 */ 40 + for (i = 0; i < IEEE_8021QAZ_MAX_TCS; i++) { 41 + if (num_tc & BIT(i)) { 42 + if (!tc_unused) { 43 + ret++; 44 + } else { 45 + pr_err("Non-contiguous TCs - Disabling DCB\n"); 46 + return 1; 47 + } 48 + } else { 49 + tc_unused = true; 50 + } 51 + } 52 + 53 + /* There is always at least 1 TC */ 54 + if (!ret) 55 + ret = 1; 56 + 57 + return ret; 58 + } 59 + 60 + /** 61 + * ice_vsi_cfg_dcb_rings - Update rings to reflect DCB TC 62 + * @vsi: VSI owner of rings being updated 63 + */ 64 + void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi) 65 + { 66 + struct ice_ring *tx_ring, *rx_ring; 67 + u16 qoffset, qcount; 68 + int i, n; 69 + 70 + if (!test_bit(ICE_FLAG_DCB_ENA, vsi->back->flags)) { 71 + /* Reset the TC information */ 72 + for (i = 0; i < vsi->num_txq; i++) { 73 + tx_ring = vsi->tx_rings[i]; 74 + tx_ring->dcb_tc = 0; 75 + } 76 + for (i = 0; i < vsi->num_rxq; i++) { 77 + rx_ring = vsi->rx_rings[i]; 78 + rx_ring->dcb_tc = 0; 79 + } 80 + return; 81 + } 82 + 83 + ice_for_each_traffic_class(n) { 84 + if (!(vsi->tc_cfg.ena_tc & BIT(n))) 85 + break; 86 + 87 + qoffset = vsi->tc_cfg.tc_info[n].qoffset; 88 + qcount = vsi->tc_cfg.tc_info[n].qcount_tx; 89 + for (i = qoffset; i < (qoffset + qcount); i++) { 90 + tx_ring = vsi->tx_rings[i]; 91 + rx_ring = vsi->rx_rings[i]; 92 + tx_ring->dcb_tc = n; 93 + rx_ring->dcb_tc = n; 94 + } 95 + } 96 + } 97 + 98 + /** 99 + * ice_pf_dcb_recfg - Reconfigure all VEBs and VSIs 100 + * @pf: pointer to the PF struct 101 + * 102 + * Assumed caller has already disabled all VSIs before 103 + * calling this function. Reconfiguring DCB based on 104 + * local_dcbx_cfg. 105 + */ 106 + static void ice_pf_dcb_recfg(struct ice_pf *pf) 107 + { 108 + struct ice_dcbx_cfg *dcbcfg = &pf->hw.port_info->local_dcbx_cfg; 109 + u8 tc_map = 0; 110 + int v, ret; 111 + 112 + /* Update each VSI */ 113 + ice_for_each_vsi(pf, v) { 114 + if (!pf->vsi[v]) 115 + continue; 116 + 117 + if (pf->vsi[v]->type == ICE_VSI_PF) 118 + tc_map = ice_dcb_get_ena_tc(dcbcfg); 119 + else 120 + tc_map = ICE_DFLT_TRAFFIC_CLASS; 121 + 122 + ret = ice_vsi_cfg_tc(pf->vsi[v], tc_map); 123 + if (ret) 124 + dev_err(&pf->pdev->dev, 125 + "Failed to config TC for VSI index: %d\n", 126 + pf->vsi[v]->idx); 127 + else 128 + ice_vsi_map_rings_to_vectors(pf->vsi[v]); 129 + } 130 + } 131 + 132 + /** 133 + * ice_pf_dcb_cfg - Apply new DCB configuration 134 + * @pf: pointer to the PF struct 135 + * @new_cfg: DCBX config to apply 136 + */ 137 + static int ice_pf_dcb_cfg(struct ice_pf *pf, struct ice_dcbx_cfg *new_cfg) 138 + { 139 + struct ice_dcbx_cfg *old_cfg, *curr_cfg; 140 + struct ice_aqc_port_ets_elem buf = { 0 }; 141 + int ret = 0; 142 + 143 + curr_cfg = &pf->hw.port_info->local_dcbx_cfg; 144 + 145 + /* Enable DCB tagging only when more than one TC */ 146 + if (ice_dcb_get_num_tc(new_cfg) > 1) { 147 + dev_dbg(&pf->pdev->dev, "DCB tagging enabled (num TC > 1)\n"); 148 + set_bit(ICE_FLAG_DCB_ENA, pf->flags); 149 + } else { 150 + dev_dbg(&pf->pdev->dev, "DCB tagging disabled (num TC = 1)\n"); 151 + clear_bit(ICE_FLAG_DCB_ENA, pf->flags); 152 + } 153 + 154 + if (!memcmp(new_cfg, curr_cfg, sizeof(*new_cfg))) { 155 + dev_dbg(&pf->pdev->dev, "No change in DCB config required\n"); 156 + return ret; 157 + } 158 + 159 + /* Store old config in case FW config fails */ 160 + old_cfg = devm_kzalloc(&pf->pdev->dev, sizeof(*old_cfg), GFP_KERNEL); 161 + memcpy(old_cfg, curr_cfg, sizeof(*old_cfg)); 162 + 163 + /* avoid race conditions by holding the lock while disabling and 164 + * re-enabling the VSI 165 + */ 166 + rtnl_lock(); 167 + ice_pf_dis_all_vsi(pf, true); 168 + 169 + memcpy(curr_cfg, new_cfg, sizeof(*curr_cfg)); 170 + memcpy(&curr_cfg->etsrec, &curr_cfg->etscfg, sizeof(curr_cfg->etsrec)); 171 + 172 + /* Only send new config to HW if we are in SW LLDP mode. Otherwise, 173 + * the new config came from the HW in the first place. 174 + */ 175 + if (pf->hw.port_info->is_sw_lldp) { 176 + ret = ice_set_dcb_cfg(pf->hw.port_info); 177 + if (ret) { 178 + dev_err(&pf->pdev->dev, "Set DCB Config failed\n"); 179 + /* Restore previous settings to local config */ 180 + memcpy(curr_cfg, old_cfg, sizeof(*curr_cfg)); 181 + goto out; 182 + } 183 + } 184 + 185 + ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); 186 + if (ret) { 187 + dev_err(&pf->pdev->dev, "Query Port ETS failed\n"); 188 + goto out; 189 + } 190 + 191 + ice_pf_dcb_recfg(pf); 192 + 193 + out: 194 + ice_pf_ena_all_vsi(pf, true); 195 + rtnl_unlock(); 196 + devm_kfree(&pf->pdev->dev, old_cfg); 197 + return ret; 198 + } 199 + 200 + /** 201 + * ice_dcb_rebuild - rebuild DCB post reset 202 + * @pf: physical function instance 203 + */ 204 + void ice_dcb_rebuild(struct ice_pf *pf) 205 + { 206 + struct ice_aqc_port_ets_elem buf = { 0 }; 207 + struct ice_dcbx_cfg *prev_cfg; 208 + enum ice_status ret; 209 + u8 willing; 210 + 211 + ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); 212 + if (ret) { 213 + dev_err(&pf->pdev->dev, "Query Port ETS failed\n"); 214 + goto dcb_error; 215 + } 216 + 217 + /* If DCB was not enabled previously, we are done */ 218 + if (!test_bit(ICE_FLAG_DCB_ENA, pf->flags)) 219 + return; 220 + 221 + /* Save current willing state and force FW to unwilling */ 222 + willing = pf->hw.port_info->local_dcbx_cfg.etscfg.willing; 223 + pf->hw.port_info->local_dcbx_cfg.etscfg.willing = 0x0; 224 + ret = ice_set_dcb_cfg(pf->hw.port_info); 225 + if (ret) { 226 + dev_err(&pf->pdev->dev, "Failed to set DCB to unwilling\n"); 227 + goto dcb_error; 228 + } 229 + 230 + /* Retrieve DCB config and ensure same as current in SW */ 231 + prev_cfg = devm_kmemdup(&pf->pdev->dev, 232 + &pf->hw.port_info->local_dcbx_cfg, 233 + sizeof(*prev_cfg), GFP_KERNEL); 234 + if (!prev_cfg) { 235 + dev_err(&pf->pdev->dev, "Failed to alloc space for DCB cfg\n"); 236 + goto dcb_error; 237 + } 238 + 239 + ice_init_dcb(&pf->hw); 240 + if (memcmp(prev_cfg, &pf->hw.port_info->local_dcbx_cfg, 241 + sizeof(*prev_cfg))) { 242 + /* difference in cfg detected - disable DCB till next MIB */ 243 + dev_err(&pf->pdev->dev, "Set local MIB not accurate\n"); 244 + devm_kfree(&pf->pdev->dev, prev_cfg); 245 + goto dcb_error; 246 + } 247 + 248 + /* fetched config congruent to previous configuration */ 249 + devm_kfree(&pf->pdev->dev, prev_cfg); 250 + 251 + /* Configuration replayed - reset willing state to previous */ 252 + pf->hw.port_info->local_dcbx_cfg.etscfg.willing = willing; 253 + ret = ice_set_dcb_cfg(pf->hw.port_info); 254 + if (ret) { 255 + dev_err(&pf->pdev->dev, "Fail restoring prev willing state\n"); 256 + goto dcb_error; 257 + } 258 + dev_info(&pf->pdev->dev, "DCB restored after reset\n"); 259 + ret = ice_query_port_ets(pf->hw.port_info, &buf, sizeof(buf), NULL); 260 + if (ret) { 261 + dev_err(&pf->pdev->dev, "Query Port ETS failed\n"); 262 + goto dcb_error; 263 + } 264 + 265 + return; 266 + 267 + dcb_error: 268 + dev_err(&pf->pdev->dev, "Disabling DCB until new settings occur\n"); 269 + prev_cfg = devm_kzalloc(&pf->pdev->dev, sizeof(*prev_cfg), GFP_KERNEL); 270 + prev_cfg->etscfg.willing = true; 271 + prev_cfg->etscfg.tcbwtable[0] = ICE_TC_MAX_BW; 272 + prev_cfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS; 273 + memcpy(&prev_cfg->etsrec, &prev_cfg->etscfg, sizeof(prev_cfg->etsrec)); 274 + ice_pf_dcb_cfg(pf, prev_cfg); 275 + devm_kfree(&pf->pdev->dev, prev_cfg); 276 + } 277 + 278 + /** 279 + * ice_dcb_init_cfg - set the initial DCB config in SW 280 + * @pf: pf to apply config to 281 + */ 282 + static int ice_dcb_init_cfg(struct ice_pf *pf) 283 + { 284 + struct ice_dcbx_cfg *newcfg; 285 + struct ice_port_info *pi; 286 + int ret = 0; 287 + 288 + pi = pf->hw.port_info; 289 + newcfg = devm_kzalloc(&pf->pdev->dev, sizeof(*newcfg), GFP_KERNEL); 290 + if (!newcfg) 291 + return -ENOMEM; 292 + 293 + memcpy(newcfg, &pi->local_dcbx_cfg, sizeof(*newcfg)); 294 + memset(&pi->local_dcbx_cfg, 0, sizeof(*newcfg)); 295 + 296 + dev_info(&pf->pdev->dev, "Configuring initial DCB values\n"); 297 + if (ice_pf_dcb_cfg(pf, newcfg)) 298 + ret = -EINVAL; 299 + 300 + devm_kfree(&pf->pdev->dev, newcfg); 301 + 302 + return ret; 303 + } 304 + 305 + /** 306 + * ice_dcb_sw_default_config - Apply a default DCB config 307 + * @pf: pf to apply config to 308 + */ 309 + static int ice_dcb_sw_dflt_cfg(struct ice_pf *pf) 310 + { 311 + struct ice_aqc_port_ets_elem buf = { 0 }; 312 + struct ice_dcbx_cfg *dcbcfg; 313 + struct ice_port_info *pi; 314 + struct ice_hw *hw; 315 + int ret; 316 + 317 + hw = &pf->hw; 318 + pi = hw->port_info; 319 + dcbcfg = devm_kzalloc(&pf->pdev->dev, sizeof(*dcbcfg), GFP_KERNEL); 320 + 321 + memset(dcbcfg, 0, sizeof(*dcbcfg)); 322 + memset(&pi->local_dcbx_cfg, 0, sizeof(*dcbcfg)); 323 + 324 + dcbcfg->etscfg.willing = 1; 325 + dcbcfg->etscfg.maxtcs = 8; 326 + dcbcfg->etscfg.tcbwtable[0] = 100; 327 + dcbcfg->etscfg.tsatable[0] = ICE_IEEE_TSA_ETS; 328 + 329 + memcpy(&dcbcfg->etsrec, &dcbcfg->etscfg, 330 + sizeof(dcbcfg->etsrec)); 331 + dcbcfg->etsrec.willing = 0; 332 + 333 + dcbcfg->pfc.willing = 1; 334 + dcbcfg->pfc.pfccap = IEEE_8021QAZ_MAX_TCS; 335 + 336 + dcbcfg->numapps = 1; 337 + dcbcfg->app[0].selector = ICE_APP_SEL_ETHTYPE; 338 + dcbcfg->app[0].priority = 3; 339 + dcbcfg->app[0].prot_id = ICE_APP_PROT_ID_FCOE; 340 + 341 + ret = ice_pf_dcb_cfg(pf, dcbcfg); 342 + devm_kfree(&pf->pdev->dev, dcbcfg); 343 + if (ret) 344 + return ret; 345 + 346 + return ice_query_port_ets(pi, &buf, sizeof(buf), NULL); 347 + } 348 + 349 + /** 350 + * ice_init_pf_dcb - initialize DCB for a PF 351 + * @pf: pf to initiialize DCB for 352 + */ 353 + int ice_init_pf_dcb(struct ice_pf *pf) 354 + { 355 + struct device *dev = &pf->pdev->dev; 356 + struct ice_port_info *port_info; 357 + struct ice_hw *hw = &pf->hw; 358 + int sw_default = 0; 359 + int err; 360 + 361 + port_info = hw->port_info; 362 + 363 + /* check if device is DCB capable */ 364 + if (!hw->func_caps.common_cap.dcb) { 365 + dev_dbg(dev, "DCB not supported\n"); 366 + return -EOPNOTSUPP; 367 + } 368 + 369 + /* Best effort to put DCBx and LLDP into a good state */ 370 + port_info->dcbx_status = ice_get_dcbx_status(hw); 371 + if (port_info->dcbx_status != ICE_DCBX_STATUS_DONE && 372 + port_info->dcbx_status != ICE_DCBX_STATUS_IN_PROGRESS) { 373 + bool dcbx_status; 374 + 375 + /* Attempt to start LLDP engine. Ignore errors 376 + * as this will error if it is already started 377 + */ 378 + ice_aq_start_lldp(hw, NULL); 379 + 380 + /* Attempt to start DCBX. Ignore errors as this 381 + * will error if it is already started 382 + */ 383 + ice_aq_start_stop_dcbx(hw, true, &dcbx_status, NULL); 384 + } 385 + 386 + err = ice_init_dcb(hw); 387 + if (err) { 388 + /* FW LLDP not in usable state, default to SW DCBx/LLDP */ 389 + dev_info(&pf->pdev->dev, "FW LLDP not in usable state\n"); 390 + hw->port_info->dcbx_status = ICE_DCBX_STATUS_NOT_STARTED; 391 + hw->port_info->is_sw_lldp = true; 392 + } 393 + 394 + if (port_info->dcbx_status == ICE_DCBX_STATUS_DIS) 395 + dev_info(&pf->pdev->dev, "DCBX disabled\n"); 396 + 397 + /* LLDP disabled in FW */ 398 + if (port_info->is_sw_lldp) { 399 + sw_default = 1; 400 + dev_info(&pf->pdev->dev, "DCBx/LLDP in SW mode.\n"); 401 + } 402 + 403 + if (port_info->dcbx_status == ICE_DCBX_STATUS_NOT_STARTED) { 404 + sw_default = 1; 405 + dev_info(&pf->pdev->dev, "DCBX not started\n"); 406 + } 407 + 408 + if (sw_default) { 409 + err = ice_dcb_sw_dflt_cfg(pf); 410 + if (err) { 411 + dev_err(&pf->pdev->dev, 412 + "Failed to set local DCB config %d\n", err); 413 + err = -EIO; 414 + goto dcb_init_err; 415 + } 416 + 417 + pf->dcbx_cap = DCB_CAP_DCBX_HOST | DCB_CAP_DCBX_VER_IEEE; 418 + set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); 419 + set_bit(ICE_FLAG_DCB_ENA, pf->flags); 420 + return 0; 421 + } 422 + 423 + /* DCBX in FW and LLDP enabled in FW */ 424 + pf->dcbx_cap = DCB_CAP_DCBX_LLD_MANAGED | DCB_CAP_DCBX_VER_IEEE; 425 + 426 + set_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); 427 + 428 + err = ice_dcb_init_cfg(pf); 429 + if (err) 430 + goto dcb_init_err; 431 + 432 + dev_info(&pf->pdev->dev, "DCBX offload supported\n"); 433 + return err; 434 + 435 + dcb_init_err: 436 + dev_err(dev, "DCB init failed\n"); 437 + return err; 438 + } 439 + 440 + /** 441 + * ice_update_dcb_stats - Update DCB stats counters 442 + * @pf: PF whose stats needs to be updated 443 + */ 444 + void ice_update_dcb_stats(struct ice_pf *pf) 445 + { 446 + struct ice_hw_port_stats *prev_ps, *cur_ps; 447 + struct ice_hw *hw = &pf->hw; 448 + u8 pf_id = hw->pf_id; 449 + int i; 450 + 451 + prev_ps = &pf->stats_prev; 452 + cur_ps = &pf->stats; 453 + 454 + for (i = 0; i < 8; i++) { 455 + ice_stat_update32(hw, GLPRT_PXOFFRXC(pf_id, i), 456 + pf->stat_prev_loaded, 457 + &prev_ps->priority_xoff_rx[i], 458 + &cur_ps->priority_xoff_rx[i]); 459 + ice_stat_update32(hw, GLPRT_PXONRXC(pf_id, i), 460 + pf->stat_prev_loaded, 461 + &prev_ps->priority_xon_rx[i], 462 + &cur_ps->priority_xon_rx[i]); 463 + ice_stat_update32(hw, GLPRT_PXONTXC(pf_id, i), 464 + pf->stat_prev_loaded, 465 + &prev_ps->priority_xon_tx[i], 466 + &cur_ps->priority_xon_tx[i]); 467 + ice_stat_update32(hw, GLPRT_PXOFFTXC(pf_id, i), 468 + pf->stat_prev_loaded, 469 + &prev_ps->priority_xoff_tx[i], 470 + &cur_ps->priority_xoff_tx[i]); 471 + ice_stat_update32(hw, GLPRT_RXON2OFFCNT(pf_id, i), 472 + pf->stat_prev_loaded, 473 + &prev_ps->priority_xon_2_xoff[i], 474 + &cur_ps->priority_xon_2_xoff[i]); 475 + } 476 + } 477 + 478 + /** 479 + * ice_tx_prepare_vlan_flags_dcb - prepare VLAN tagging for DCB 480 + * @tx_ring: ring to send buffer on 481 + * @first: pointer to struct ice_tx_buf 482 + */ 483 + int 484 + ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring, 485 + struct ice_tx_buf *first) 486 + { 487 + struct sk_buff *skb = first->skb; 488 + 489 + if (!test_bit(ICE_FLAG_DCB_ENA, tx_ring->vsi->back->flags)) 490 + return 0; 491 + 492 + /* Insert 802.1p priority into VLAN header */ 493 + if ((first->tx_flags & (ICE_TX_FLAGS_HW_VLAN | ICE_TX_FLAGS_SW_VLAN)) || 494 + skb->priority != TC_PRIO_CONTROL) { 495 + first->tx_flags &= ~ICE_TX_FLAGS_VLAN_PR_M; 496 + /* Mask the lower 3 bits to set the 802.1p priority */ 497 + first->tx_flags |= (skb->priority & 0x7) << 498 + ICE_TX_FLAGS_VLAN_PR_S; 499 + if (first->tx_flags & ICE_TX_FLAGS_SW_VLAN) { 500 + struct vlan_ethhdr *vhdr; 501 + int rc; 502 + 503 + rc = skb_cow_head(skb, 0); 504 + if (rc < 0) 505 + return rc; 506 + vhdr = (struct vlan_ethhdr *)skb->data; 507 + vhdr->h_vlan_TCI = htons(first->tx_flags >> 508 + ICE_TX_FLAGS_VLAN_S); 509 + } else { 510 + first->tx_flags |= ICE_TX_FLAGS_HW_VLAN; 511 + } 512 + } 513 + 514 + return 0; 515 + } 516 + 517 + /** 518 + * ice_dcb_process_lldp_set_mib_change - Process MIB change 519 + * @pf: ptr to ice_pf 520 + * @event: pointer to the admin queue receive event 521 + */ 522 + void 523 + ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, 524 + struct ice_rq_event_info *event) 525 + { 526 + if (pf->dcbx_cap & DCB_CAP_DCBX_LLD_MANAGED) { 527 + struct ice_dcbx_cfg *dcbcfg, *prev_cfg; 528 + int err; 529 + 530 + prev_cfg = &pf->hw.port_info->local_dcbx_cfg; 531 + dcbcfg = devm_kmemdup(&pf->pdev->dev, prev_cfg, 532 + sizeof(*dcbcfg), GFP_KERNEL); 533 + if (!dcbcfg) 534 + return; 535 + 536 + err = ice_lldp_to_dcb_cfg(event->msg_buf, dcbcfg); 537 + if (!err) 538 + ice_pf_dcb_cfg(pf, dcbcfg); 539 + 540 + devm_kfree(&pf->pdev->dev, dcbcfg); 541 + 542 + /* Get updated DCBx data from firmware */ 543 + err = ice_get_dcb_cfg(pf->hw.port_info); 544 + if (err) 545 + dev_err(&pf->pdev->dev, 546 + "Failed to get DCB config\n"); 547 + } else { 548 + dev_dbg(&pf->pdev->dev, 549 + "MIB Change Event in HOST mode\n"); 550 + } 551 + }
+61
drivers/net/ethernet/intel/ice/ice_dcb_lib.h
··· 1 + /* SPDX-License-Identifier: GPL-2.0 */ 2 + /* Copyright (c) 2019, Intel Corporation. */ 3 + 4 + #ifndef _ICE_DCB_LIB_H_ 5 + #define _ICE_DCB_LIB_H_ 6 + 7 + #include "ice.h" 8 + #include "ice_lib.h" 9 + 10 + #ifdef CONFIG_DCB 11 + #define ICE_TC_MAX_BW 100 /* Default Max BW percentage */ 12 + 13 + void ice_dcb_rebuild(struct ice_pf *pf); 14 + u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg *dcbcfg); 15 + u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg *dcbcfg); 16 + void ice_vsi_cfg_dcb_rings(struct ice_vsi *vsi); 17 + int ice_init_pf_dcb(struct ice_pf *pf); 18 + void ice_update_dcb_stats(struct ice_pf *pf); 19 + int 20 + ice_tx_prepare_vlan_flags_dcb(struct ice_ring *tx_ring, 21 + struct ice_tx_buf *first); 22 + void 23 + ice_dcb_process_lldp_set_mib_change(struct ice_pf *pf, 24 + struct ice_rq_event_info *event); 25 + static inline void 26 + ice_set_cgd_num(struct ice_tlan_ctx *tlan_ctx, struct ice_ring *ring) 27 + { 28 + tlan_ctx->cgd_num = ring->dcb_tc; 29 + } 30 + #else 31 + #define ice_dcb_rebuild(pf) do {} while (0) 32 + 33 + static inline u8 ice_dcb_get_ena_tc(struct ice_dcbx_cfg __always_unused *dcbcfg) 34 + { 35 + return ICE_DFLT_TRAFFIC_CLASS; 36 + } 37 + 38 + static inline u8 ice_dcb_get_num_tc(struct ice_dcbx_cfg __always_unused *dcbcfg) 39 + { 40 + return 1; 41 + } 42 + 43 + static inline int ice_init_pf_dcb(struct ice_pf *pf) 44 + { 45 + dev_dbg(&pf->pdev->dev, "DCB not supported\n"); 46 + return -EOPNOTSUPP; 47 + } 48 + 49 + static inline int 50 + ice_tx_prepare_vlan_flags_dcb(struct ice_ring __always_unused *tx_ring, 51 + struct ice_tx_buf __always_unused *first) 52 + { 53 + return 0; 54 + } 55 + 56 + #define ice_update_dcb_stats(pf) do {} while (0) 57 + #define ice_vsi_cfg_dcb_rings(vsi) do {} while (0) 58 + #define ice_dcb_process_lldp_set_mib_change(pf, event) do {} while (0) 59 + #define ice_set_cgd_num(tlan_ctx, ring) do {} while (0) 60 + #endif /* CONFIG_DCB */ 61 + #endif /* _ICE_DCB_LIB_H_ */
+139 -13
drivers/net/ethernet/intel/ice/ice_ethtool.c
··· 4 4 /* ethtool support for ice */ 5 5 6 6 #include "ice.h" 7 + #include "ice_lib.h" 8 + #include "ice_dcb_lib.h" 7 9 8 10 struct ice_stats { 9 11 char stat_string[ETH_GSTRING_LEN]; ··· 35 33 #define ICE_PF_STATS_LEN ARRAY_SIZE(ice_gstrings_pf_stats) 36 34 #define ICE_VSI_STATS_LEN ARRAY_SIZE(ice_gstrings_vsi_stats) 37 35 38 - #define ICE_ALL_STATS_LEN(n) (ICE_PF_STATS_LEN + ICE_VSI_STATS_LEN + \ 39 - ice_q_stats_len(n)) 36 + #define ICE_PFC_STATS_LEN ( \ 37 + (FIELD_SIZEOF(struct ice_pf, stats.priority_xoff_rx) + \ 38 + FIELD_SIZEOF(struct ice_pf, stats.priority_xon_rx) + \ 39 + FIELD_SIZEOF(struct ice_pf, stats.priority_xoff_tx) + \ 40 + FIELD_SIZEOF(struct ice_pf, stats.priority_xon_tx)) \ 41 + / sizeof(u64)) 42 + #define ICE_ALL_STATS_LEN(n) (ICE_PF_STATS_LEN + ICE_PFC_STATS_LEN + \ 43 + ICE_VSI_STATS_LEN + ice_q_stats_len(n)) 40 44 41 45 static const struct ice_stats ice_gstrings_vsi_stats[] = { 42 46 ICE_VSI_STAT("tx_unicast", eth_stats.tx_unicast), ··· 134 126 135 127 static const struct ice_priv_flag ice_gstrings_priv_flags[] = { 136 128 ICE_PRIV_FLAG("link-down-on-close", ICE_FLAG_LINK_DOWN_ON_CLOSE_ENA), 129 + ICE_PRIV_FLAG("disable-fw-lldp", ICE_FLAG_DISABLE_FW_LLDP), 137 130 }; 138 131 139 132 #define ICE_PRIV_FLAG_ARRAY_SIZE ARRAY_SIZE(ice_gstrings_priv_flags) ··· 318 309 p += ETH_GSTRING_LEN; 319 310 } 320 311 312 + for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) { 313 + snprintf(p, ETH_GSTRING_LEN, 314 + "port.tx-priority-%u-xon", i); 315 + p += ETH_GSTRING_LEN; 316 + snprintf(p, ETH_GSTRING_LEN, 317 + "port.tx-priority-%u-xoff", i); 318 + p += ETH_GSTRING_LEN; 319 + } 320 + for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) { 321 + snprintf(p, ETH_GSTRING_LEN, 322 + "port.rx-priority-%u-xon", i); 323 + p += ETH_GSTRING_LEN; 324 + snprintf(p, ETH_GSTRING_LEN, 325 + "port.rx-priority-%u-xoff", i); 326 + p += ETH_GSTRING_LEN; 327 + } 321 328 break; 322 329 case ETH_SS_PRIV_FLAGS: 323 330 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) { ··· 407 382 static int ice_set_priv_flags(struct net_device *netdev, u32 flags) 408 383 { 409 384 struct ice_netdev_priv *np = netdev_priv(netdev); 385 + DECLARE_BITMAP(change_flags, ICE_PF_FLAGS_NBITS); 386 + DECLARE_BITMAP(orig_flags, ICE_PF_FLAGS_NBITS); 410 387 struct ice_vsi *vsi = np->vsi; 411 388 struct ice_pf *pf = vsi->back; 389 + int ret = 0; 412 390 u32 i; 413 391 414 392 if (flags > BIT(ICE_PRIV_FLAG_ARRAY_SIZE)) 415 393 return -EINVAL; 416 394 395 + set_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); 396 + 397 + bitmap_copy(orig_flags, pf->flags, ICE_PF_FLAGS_NBITS); 417 398 for (i = 0; i < ICE_PRIV_FLAG_ARRAY_SIZE; i++) { 418 399 const struct ice_priv_flag *priv_flag; 419 400 ··· 431 400 clear_bit(priv_flag->bitno, pf->flags); 432 401 } 433 402 434 - return 0; 403 + bitmap_xor(change_flags, pf->flags, orig_flags, ICE_PF_FLAGS_NBITS); 404 + 405 + if (test_bit(ICE_FLAG_DISABLE_FW_LLDP, change_flags)) { 406 + if (test_bit(ICE_FLAG_DISABLE_FW_LLDP, pf->flags)) { 407 + enum ice_status status; 408 + 409 + status = ice_aq_cfg_lldp_mib_change(&pf->hw, false, 410 + NULL); 411 + /* If unregistering for LLDP events fails, this is 412 + * not an error state, as there shouldn't be any 413 + * events to respond to. 414 + */ 415 + if (status) 416 + dev_info(&pf->pdev->dev, 417 + "Failed to unreg for LLDP events\n"); 418 + 419 + /* The AQ call to stop the FW LLDP agent will generate 420 + * an error if the agent is already stopped. 421 + */ 422 + status = ice_aq_stop_lldp(&pf->hw, true, NULL); 423 + if (status) 424 + dev_warn(&pf->pdev->dev, 425 + "Fail to stop LLDP agent\n"); 426 + /* Use case for having the FW LLDP agent stopped 427 + * will likely not need DCB, so failure to init is 428 + * not a concern of ethtool 429 + */ 430 + status = ice_init_pf_dcb(pf); 431 + if (status) 432 + dev_warn(&pf->pdev->dev, "Fail to init DCB\n"); 433 + } else { 434 + enum ice_status status; 435 + bool dcbx_agent_status; 436 + 437 + /* AQ command to start FW LLDP agent will return an 438 + * error if the agent is already started 439 + */ 440 + status = ice_aq_start_lldp(&pf->hw, NULL); 441 + if (status) 442 + dev_warn(&pf->pdev->dev, 443 + "Fail to start LLDP Agent\n"); 444 + 445 + /* AQ command to start FW DCBx agent will fail if 446 + * the agent is already started 447 + */ 448 + status = ice_aq_start_stop_dcbx(&pf->hw, true, 449 + &dcbx_agent_status, 450 + NULL); 451 + if (status) 452 + dev_dbg(&pf->pdev->dev, 453 + "Failed to start FW DCBX\n"); 454 + 455 + dev_info(&pf->pdev->dev, "FW DCBX agent is %s\n", 456 + dcbx_agent_status ? "ACTIVE" : "DISABLED"); 457 + 458 + /* Failure to configure MIB change or init DCB is not 459 + * relevant to ethtool. Print notification that 460 + * registration/init failed but do not return error 461 + * state to ethtool 462 + */ 463 + status = ice_aq_cfg_lldp_mib_change(&pf->hw, false, 464 + NULL); 465 + if (status) 466 + dev_dbg(&pf->pdev->dev, 467 + "Fail to reg for MIB change\n"); 468 + 469 + status = ice_init_pf_dcb(pf); 470 + if (status) 471 + dev_dbg(&pf->pdev->dev, "Fail to init DCB\n"); 472 + } 473 + } 474 + clear_bit(ICE_FLAG_ETHTOOL_CTXT, pf->flags); 475 + return ret; 435 476 } 436 477 437 478 static int ice_get_sset_count(struct net_device *netdev, int sset) ··· 588 485 p = (char *)pf + ice_gstrings_pf_stats[j].stat_offset; 589 486 data[i++] = (ice_gstrings_pf_stats[j].sizeof_stat == 590 487 sizeof(u64)) ? *(u64 *)p : *(u32 *)p; 488 + } 489 + 490 + for (j = 0; j < ICE_MAX_USER_PRIORITY; j++) { 491 + data[i++] = pf->stats.priority_xon_tx[j]; 492 + data[i++] = pf->stats.priority_xoff_tx[j]; 493 + } 494 + 495 + for (j = 0; j < ICE_MAX_USER_PRIORITY; j++) { 496 + data[i++] = pf->stats.priority_xon_rx[j]; 497 + data[i++] = pf->stats.priority_xoff_rx[j]; 591 498 } 592 499 } 593 500 ··· 924 811 925 812 link_info = &vsi->port_info->phy.link_info; 926 813 927 - /* Initialize supported and advertised settings based on phy settings */ 814 + /* Initialize supported and advertised settings based on PHY settings */ 928 815 switch (link_info->phy_type_low) { 929 816 case ICE_PHY_TYPE_LOW_100BASE_TX: 930 817 ethtool_link_ksettings_add_link_mode(ks, supported, Autoneg); ··· 1253 1140 struct net_device __always_unused *netdev) 1254 1141 { 1255 1142 /* link is down and the driver needs to fall back on 1256 - * supported phy types to figure out what info to display 1143 + * supported PHY types to figure out what info to display 1257 1144 */ 1258 1145 ice_phy_type_to_ethtool(netdev, ks); 1259 1146 ··· 1463 1350 } else { 1464 1351 /* If autoneg is currently enabled */ 1465 1352 if (p->phy.link_info.an_info & ICE_AQ_AN_COMPLETED) { 1466 - /* If autoneg is supported 10GBASE_T is the only phy 1353 + /* If autoneg is supported 10GBASE_T is the only PHY 1467 1354 * that can disable it, so otherwise return error 1468 1355 */ 1469 1356 if (ethtool_link_ksettings_test_link_mode(ks, ··· 1513 1400 if (!p) 1514 1401 return -EOPNOTSUPP; 1515 1402 1516 - /* Check if this is lan vsi */ 1403 + /* Check if this is LAN VSI */ 1517 1404 ice_for_each_vsi(pf, idx) 1518 1405 if (pf->vsi[idx]->type == ICE_VSI_PF) { 1519 1406 if (np->vsi != pf->vsi[idx]) ··· 1577 1464 if (!abilities) 1578 1465 return -ENOMEM; 1579 1466 1580 - /* Get the current phy config */ 1467 + /* Get the current PHY config */ 1581 1468 status = ice_aq_get_phy_caps(p, false, ICE_AQC_REPORT_SW_CFG, abilities, 1582 1469 NULL); 1583 1470 if (status) { ··· 1672 1559 } 1673 1560 1674 1561 /** 1675 - * ice_get_rxnfc - command to get RX flow classification rules 1562 + * ice_get_rxnfc - command to get Rx flow classification rules 1676 1563 * @netdev: network interface device structure 1677 1564 * @cmd: ethtool rxnfc command 1678 1565 * @rule_locs: buffer to rturn Rx flow classification rules ··· 1935 1822 struct ice_port_info *pi = np->vsi->port_info; 1936 1823 struct ice_aqc_get_phy_caps_data *pcaps; 1937 1824 struct ice_vsi *vsi = np->vsi; 1825 + struct ice_dcbx_cfg *dcbx_cfg; 1938 1826 enum ice_status status; 1939 1827 1940 1828 /* Initialize pause params */ 1941 1829 pause->rx_pause = 0; 1942 1830 pause->tx_pause = 0; 1943 1831 1832 + dcbx_cfg = &pi->local_dcbx_cfg; 1833 + 1944 1834 pcaps = devm_kzalloc(&vsi->back->pdev->dev, sizeof(*pcaps), 1945 1835 GFP_KERNEL); 1946 1836 if (!pcaps) 1947 1837 return; 1948 1838 1949 - /* Get current phy config */ 1839 + /* Get current PHY config */ 1950 1840 status = ice_aq_get_phy_caps(pi, false, ICE_AQC_REPORT_SW_CFG, pcaps, 1951 1841 NULL); 1952 1842 if (status) ··· 1957 1841 1958 1842 pause->autoneg = ((pcaps->caps & ICE_AQC_PHY_AN_MODE) ? 1959 1843 AUTONEG_ENABLE : AUTONEG_DISABLE); 1844 + 1845 + if (dcbx_cfg->pfc.pfcena) 1846 + /* PFC enabled so report LFC as off */ 1847 + goto out; 1960 1848 1961 1849 if (pcaps->caps & ICE_AQC_PHY_EN_TX_LINK_PAUSE) 1962 1850 pause->tx_pause = 1; ··· 1982 1862 struct ice_netdev_priv *np = netdev_priv(netdev); 1983 1863 struct ice_link_status *hw_link_info; 1984 1864 struct ice_pf *pf = np->vsi->back; 1865 + struct ice_dcbx_cfg *dcbx_cfg; 1985 1866 struct ice_vsi *vsi = np->vsi; 1986 1867 struct ice_hw *hw = &pf->hw; 1987 1868 struct ice_port_info *pi; ··· 1993 1872 1994 1873 pi = vsi->port_info; 1995 1874 hw_link_info = &pi->phy.link_info; 1875 + dcbx_cfg = &pi->local_dcbx_cfg; 1996 1876 link_up = hw_link_info->link_info & ICE_AQ_LINK_UP; 1997 1877 1998 1878 /* Changing the port's flow control is not supported if this isn't the ··· 2016 1894 netdev_info(netdev, "Autoneg did not complete so changing settings may not result in an actual change.\n"); 2017 1895 } 2018 1896 1897 + if (dcbx_cfg->pfc.pfcena) { 1898 + netdev_info(netdev, "Priority flow control enabled. Cannot set link flow control.\n"); 1899 + return -EOPNOTSUPP; 1900 + } 2019 1901 if (pause->rx_pause && pause->tx_pause) 2020 1902 pi->fc.req_mode = ICE_FC_FULL; 2021 1903 else if (pause->rx_pause && !pause->tx_pause) ··· 2148 2022 * @key: hash key 2149 2023 * @hfunc: hash function 2150 2024 * 2151 - * Returns -EINVAL if the table specifies an invalid queue id, otherwise 2025 + * Returns -EINVAL if the table specifies an invalid queue ID, otherwise 2152 2026 * returns 0 after programming the table. 2153 2027 */ 2154 2028 static int ··· 2215 2089 /** 2216 2090 * ice_get_rc_coalesce - get ITR values for specific ring container 2217 2091 * @ec: ethtool structure to fill with driver's coalesce settings 2218 - * @c_type: container type, RX or TX 2092 + * @c_type: container type, Rx or Tx 2219 2093 * @rc: ring container that the ITR values will come from 2220 2094 * 2221 2095 * Query the device for ice_ring_container specific ITR values. This is ··· 2317 2191 2318 2192 /** 2319 2193 * ice_set_rc_coalesce - set ITR values for specific ring container 2320 - * @c_type: container type, RX or TX 2194 + * @c_type: container type, Rx or Tx 2321 2195 * @ec: ethtool structure from user to update ITR settings 2322 2196 * @rc: ring container that the ITR values will come from 2323 2197 * @vsi: VSI associated to the ring container
+8
drivers/net/ethernet/intel/ice/ice_hw_autogen.h
··· 49 49 #define PF_MBX_ATQLEN_ATQLEN_M ICE_M(0x3FF, 0) 50 50 #define PF_MBX_ATQLEN_ATQENABLE_M BIT(31) 51 51 #define PF_MBX_ATQT 0x0022E300 52 + #define PRTDCB_GENS 0x00083020 53 + #define PRTDCB_GENS_DCBX_STATUS_S 0 54 + #define PRTDCB_GENS_DCBX_STATUS_M ICE_M(0x7, 0) 52 55 #define GLFLXP_RXDID_FLAGS(_i, _j) (0x0045D000 + ((_i) * 4 + (_j) * 256)) 53 56 #define GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_S 0 54 57 #define GLFLXP_RXDID_FLAGS_FLEXIFLAG_4N_M ICE_M(0x3F, 0) ··· 321 318 #define GLPRT_PTC64L(_i) (0x00380B80 + ((_i) * 8)) 322 319 #define GLPRT_PTC9522H(_i) (0x00380D04 + ((_i) * 8)) 323 320 #define GLPRT_PTC9522L(_i) (0x00380D00 + ((_i) * 8)) 321 + #define GLPRT_PXOFFRXC(_i, _j) (0x00380500 + ((_i) * 8 + (_j) * 64)) 322 + #define GLPRT_PXOFFTXC(_i, _j) (0x00380F40 + ((_i) * 8 + (_j) * 64)) 323 + #define GLPRT_PXONRXC(_i, _j) (0x00380300 + ((_i) * 8 + (_j) * 64)) 324 + #define GLPRT_PXONTXC(_i, _j) (0x00380D40 + ((_i) * 8 + (_j) * 64)) 324 325 #define GLPRT_RFC(_i) (0x00380AC0 + ((_i) * 8)) 325 326 #define GLPRT_RJC(_i) (0x00380B00 + ((_i) * 8)) 326 327 #define GLPRT_RLEC(_i) (0x00380140 + ((_i) * 8)) 327 328 #define GLPRT_ROC(_i) (0x00380240 + ((_i) * 8)) 328 329 #define GLPRT_RUC(_i) (0x00380200 + ((_i) * 8)) 330 + #define GLPRT_RXON2OFFCNT(_i, _j) (0x00380700 + ((_i) * 8 + (_j) * 64)) 329 331 #define GLPRT_TDOLD(_i) (0x00381280 + ((_i) * 8)) 330 332 #define GLPRT_UPRCH(_i) (0x00381304 + ((_i) * 8)) 331 333 #define GLPRT_UPRCL(_i) (0x00381300 + ((_i) * 8))
+6 -6
drivers/net/ethernet/intel/ice/ice_lan_tx_rx.h
··· 20 20 } lo_dword; 21 21 union { 22 22 __le32 rss; /* RSS Hash */ 23 - __le32 fd_id; /* Flow Director filter id */ 23 + __le32 fd_id; /* Flow Director filter ID */ 24 24 } hi_dword; 25 25 } qword0; 26 26 struct { ··· 99 99 ICE_RX_PTYPE_PAYLOAD_LAYER_PAY4 = 3, 100 100 }; 101 101 102 - /* RX Flex Descriptor 102 + /* Rx Flex Descriptor 103 103 * This descriptor is used instead of the legacy version descriptor when 104 104 * ice_rlan_ctx.adv_desc is set 105 105 */ ··· 113 113 } read; 114 114 struct { 115 115 /* Qword 0 */ 116 - u8 rxdid; /* descriptor builder profile id */ 116 + u8 rxdid; /* descriptor builder profile ID */ 117 117 u8 mir_id_umb_cast; /* mirror=[5:0], umb=[7:6] */ 118 118 __le16 ptype_flex_flags0; /* ptype=[9:0], ff0=[15:10] */ 119 119 __le16 pkt_len; /* [15:14] are reserved */ ··· 149 149 150 150 /* Rx Flex Descriptor NIC Profile 151 151 * This descriptor corresponds to RxDID 2 which contains 152 - * metadata fields for RSS, flow id and timestamp info 152 + * metadata fields for RSS, flow ID and timestamp info 153 153 */ 154 154 struct ice_32b_rx_flex_desc_nic { 155 155 /* Qword 0 */ ··· 208 208 ICE_RX_MDID_HASH_HIGH, 209 209 }; 210 210 211 - /* RX/TX Flag64 packet flag bits */ 211 + /* Rx/Tx Flag64 packet flag bits */ 212 212 enum ice_flg64_bits { 213 213 ICE_FLG_PKT_DSI = 0, 214 214 ICE_FLG_EVLAN_x8100 = 15, ··· 322 322 ICE_RLAN_RX_HSPLIT_1_SPLIT_ALWAYS = 2, 323 323 }; 324 324 325 - /* TX Descriptor */ 325 + /* Tx Descriptor */ 326 326 struct ice_tx_desc { 327 327 __le64 buf_addr; /* Address of descriptor's data buf */ 328 328 __le64 cmd_type_offset_bsz;
+149 -12
drivers/net/ethernet/intel/ice/ice_lib.c
··· 3 3 4 4 #include "ice.h" 5 5 #include "ice_lib.h" 6 + #include "ice_dcb_lib.h" 6 7 7 8 /** 8 9 * ice_setup_rx_ctx - Configure a receive ring context ··· 74 73 regval |= (rxdid << QRXFLXP_CNTXT_RXDID_IDX_S) & 75 74 QRXFLXP_CNTXT_RXDID_IDX_M; 76 75 77 - /* increasing context priority to pick up profile id; 76 + /* increasing context priority to pick up profile ID; 78 77 * default is 0x01; setting to 0x03 to ensure profile 79 78 * is programming if prev context is of same priority 80 79 */ ··· 125 124 /* Transmit Queue Length */ 126 125 tlan_ctx->qlen = ring->count; 127 126 127 + ice_set_cgd_num(tlan_ctx, ring); 128 + 128 129 /* PF number */ 129 130 tlan_ctx->pf_num = hw->pf_id; 130 131 ··· 141 138 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_PF; 142 139 break; 143 140 case ICE_VSI_VF: 144 - /* Firmware expects vmvf_num to be absolute VF id */ 141 + /* Firmware expects vmvf_num to be absolute VF ID */ 145 142 tlan_ctx->vmvf_num = hw->func_caps.vf_base_id + vsi->vf_id; 146 143 tlan_ctx->vmvf_type = ICE_TLAN_CTX_VMVF_TYPE_VF; 147 144 break; ··· 300 297 /** 301 298 * ice_vsi_set_num_qs - Set number of queues, descriptors and vectors for a VSI 302 299 * @vsi: the VSI being configured 303 - * @vf_id: Id of the VF being configured 300 + * @vf_id: ID of the VF being configured 304 301 * 305 302 * Return 0 on success and a negative value on error 306 303 */ ··· 482 479 * ice_vsi_alloc - Allocates the next available struct VSI in the PF 483 480 * @pf: board private structure 484 481 * @type: type of VSI 485 - * @vf_id: Id of the VF being configured 482 + * @vf_id: ID of the VF being configured 486 483 * 487 484 * returns a pointer to a VSI on success, NULL on failure. 488 485 */ ··· 1304 1301 * through the MSI-X enabling code. On a constrained vector budget, we map Tx 1305 1302 * and Rx rings to the vector as "efficiently" as possible. 1306 1303 */ 1304 + #ifdef CONFIG_DCB 1305 + void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi) 1306 + #else 1307 1307 static void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi) 1308 + #endif /* CONFIG_DCB */ 1308 1309 { 1309 1310 int q_vectors = vsi->num_q_vectors; 1310 1311 int tx_rings_rem, rx_rings_rem; ··· 1452 1445 } 1453 1446 1454 1447 /** 1455 - * ice_add_mac_to_list - Add a mac address filter entry to the list 1448 + * ice_add_mac_to_list - Add a MAC address filter entry to the list 1456 1449 * @vsi: the VSI to be forwarded to 1457 1450 * @add_list: pointer to the list which contains MAC filter entries 1458 1451 * @macaddr: the MAC address to be added. 1459 1452 * 1460 - * Adds mac address filter entry to the temp list 1453 + * Adds MAC address filter entry to the temp list 1461 1454 * 1462 1455 * Returns 0 on success or ENOMEM on failure. 1463 1456 */ ··· 1559 1552 /** 1560 1553 * ice_vsi_add_vlan - Add VSI membership for given VLAN 1561 1554 * @vsi: the VSI being configured 1562 - * @vid: VLAN id to be added 1555 + * @vid: VLAN ID to be added 1563 1556 */ 1564 1557 int ice_vsi_add_vlan(struct ice_vsi *vsi, u16 vid) 1565 1558 { ··· 1597 1590 /** 1598 1591 * ice_vsi_kill_vlan - Remove VSI membership for a given VLAN 1599 1592 * @vsi: the VSI being configured 1600 - * @vid: VLAN id to be removed 1593 + * @vid: VLAN ID to be removed 1601 1594 * 1602 1595 * Returns 0 on success and negative on failure 1603 1596 */ ··· 2023 2016 * ice_vsi_stop_tx_rings - Disable Tx rings 2024 2017 * @vsi: the VSI being configured 2025 2018 * @rst_src: reset source 2026 - * @rel_vmvf_num: Relative id of VF/VM 2019 + * @rel_vmvf_num: Relative ID of VF/VM 2027 2020 * @rings: Tx ring array to be stopped 2028 2021 * @offset: offset within vsi->txq_map 2029 2022 */ ··· 2109 2102 * ice_vsi_stop_lan_tx_rings - Disable LAN Tx rings 2110 2103 * @vsi: the VSI being configured 2111 2104 * @rst_src: reset source 2112 - * @rel_vmvf_num: Relative id of VF/VM 2105 + * @rel_vmvf_num: Relative ID of VF/VM 2113 2106 */ 2114 2107 int 2115 2108 ice_vsi_stop_lan_tx_rings(struct ice_vsi *vsi, enum ice_disq_rst_src rst_src, ··· 2179 2172 return -EIO; 2180 2173 } 2181 2174 2175 + static void ice_vsi_set_tc_cfg(struct ice_vsi *vsi) 2176 + { 2177 + struct ice_dcbx_cfg *cfg = &vsi->port_info->local_dcbx_cfg; 2178 + 2179 + vsi->tc_cfg.ena_tc = ice_dcb_get_ena_tc(cfg); 2180 + vsi->tc_cfg.numtc = ice_dcb_get_num_tc(cfg); 2181 + } 2182 + 2182 2183 /** 2183 2184 * ice_vsi_setup - Set up a VSI by a given type 2184 2185 * @pf: board private structure 2185 2186 * @pi: pointer to the port_info instance 2186 2187 * @type: VSI type 2187 - * @vf_id: defines VF id to which this VSI connects. This field is meant to be 2188 + * @vf_id: defines VF ID to which this VSI connects. This field is meant to be 2188 2189 * used only for ICE_VSI_VF VSI type. For other VSI types, should 2189 2190 * fill-in ICE_INVAL_VFID as input. 2190 2191 * ··· 2234 2219 /* set RSS capabilities */ 2235 2220 ice_vsi_set_rss_params(vsi); 2236 2221 2237 - /* set tc configuration */ 2222 + /* set TC configuration */ 2238 2223 ice_vsi_set_tc_cfg(vsi); 2239 2224 2240 2225 /* create the VSI */ ··· 2830 2815 test_bit(__ICE_CORER_REQ, state) || 2831 2816 test_bit(__ICE_GLOBR_REQ, state); 2832 2817 } 2818 + 2819 + #ifdef CONFIG_DCB 2820 + /** 2821 + * ice_vsi_update_q_map - update our copy of the VSI info with new queue map 2822 + * @vsi: VSI being configured 2823 + * @ctx: the context buffer returned from AQ VSI update command 2824 + */ 2825 + static void ice_vsi_update_q_map(struct ice_vsi *vsi, struct ice_vsi_ctx *ctx) 2826 + { 2827 + vsi->info.mapping_flags = ctx->info.mapping_flags; 2828 + memcpy(&vsi->info.q_mapping, &ctx->info.q_mapping, 2829 + sizeof(vsi->info.q_mapping)); 2830 + memcpy(&vsi->info.tc_mapping, ctx->info.tc_mapping, 2831 + sizeof(vsi->info.tc_mapping)); 2832 + } 2833 + 2834 + /** 2835 + * ice_vsi_cfg_netdev_tc - Setup the netdev TC configuration 2836 + * @vsi: the VSI being configured 2837 + * @ena_tc: TC map to be enabled 2838 + */ 2839 + static void ice_vsi_cfg_netdev_tc(struct ice_vsi *vsi, u8 ena_tc) 2840 + { 2841 + struct net_device *netdev = vsi->netdev; 2842 + struct ice_pf *pf = vsi->back; 2843 + struct ice_dcbx_cfg *dcbcfg; 2844 + u8 netdev_tc; 2845 + int i; 2846 + 2847 + if (!netdev) 2848 + return; 2849 + 2850 + if (!ena_tc) { 2851 + netdev_reset_tc(netdev); 2852 + return; 2853 + } 2854 + 2855 + if (netdev_set_num_tc(netdev, vsi->tc_cfg.numtc)) 2856 + return; 2857 + 2858 + dcbcfg = &pf->hw.port_info->local_dcbx_cfg; 2859 + 2860 + ice_for_each_traffic_class(i) 2861 + if (vsi->tc_cfg.ena_tc & BIT(i)) 2862 + netdev_set_tc_queue(netdev, 2863 + vsi->tc_cfg.tc_info[i].netdev_tc, 2864 + vsi->tc_cfg.tc_info[i].qcount_tx, 2865 + vsi->tc_cfg.tc_info[i].qoffset); 2866 + 2867 + for (i = 0; i < ICE_MAX_USER_PRIORITY; i++) { 2868 + u8 ets_tc = dcbcfg->etscfg.prio_table[i]; 2869 + 2870 + /* Get the mapped netdev TC# for the UP */ 2871 + netdev_tc = vsi->tc_cfg.tc_info[ets_tc].netdev_tc; 2872 + netdev_set_prio_tc_map(netdev, i, netdev_tc); 2873 + } 2874 + } 2875 + 2876 + /** 2877 + * ice_vsi_cfg_tc - Configure VSI Tx Sched for given TC map 2878 + * @vsi: VSI to be configured 2879 + * @ena_tc: TC bitmap 2880 + * 2881 + * VSI queues expected to be quiesced before calling this function 2882 + */ 2883 + int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc) 2884 + { 2885 + u16 max_txqs[ICE_MAX_TRAFFIC_CLASS] = { 0 }; 2886 + struct ice_vsi_ctx *ctx; 2887 + struct ice_pf *pf = vsi->back; 2888 + enum ice_status status; 2889 + int i, ret = 0; 2890 + u8 num_tc = 0; 2891 + 2892 + ice_for_each_traffic_class(i) { 2893 + /* build bitmap of enabled TCs */ 2894 + if (ena_tc & BIT(i)) 2895 + num_tc++; 2896 + /* populate max_txqs per TC */ 2897 + max_txqs[i] = pf->num_lan_tx; 2898 + } 2899 + 2900 + vsi->tc_cfg.ena_tc = ena_tc; 2901 + vsi->tc_cfg.numtc = num_tc; 2902 + 2903 + ctx = devm_kzalloc(&pf->pdev->dev, sizeof(*ctx), GFP_KERNEL); 2904 + if (!ctx) 2905 + return -ENOMEM; 2906 + 2907 + ctx->vf_num = 0; 2908 + ctx->info = vsi->info; 2909 + 2910 + ice_vsi_setup_q_map(vsi, ctx); 2911 + 2912 + /* must to indicate which section of VSI context are being modified */ 2913 + ctx->info.valid_sections = cpu_to_le16(ICE_AQ_VSI_PROP_RXQ_MAP_VALID); 2914 + status = ice_update_vsi(&pf->hw, vsi->idx, ctx, NULL); 2915 + if (status) { 2916 + dev_info(&pf->pdev->dev, "Failed VSI Update\n"); 2917 + ret = -EIO; 2918 + goto out; 2919 + } 2920 + 2921 + status = ice_cfg_vsi_lan(vsi->port_info, vsi->idx, vsi->tc_cfg.ena_tc, 2922 + max_txqs); 2923 + 2924 + if (status) { 2925 + dev_err(&pf->pdev->dev, 2926 + "VSI %d failed TC config, error %d\n", 2927 + vsi->vsi_num, status); 2928 + ret = -EIO; 2929 + goto out; 2930 + } 2931 + ice_vsi_update_q_map(vsi, ctx); 2932 + vsi->info.valid_sections = 0; 2933 + 2934 + ice_vsi_cfg_netdev_tc(vsi, ena_tc); 2935 + out: 2936 + devm_kfree(&pf->pdev->dev, ctx); 2937 + return ret; 2938 + } 2939 + #endif /* CONFIG_DCB */
+8
drivers/net/ethernet/intel/ice/ice_lib.h
··· 41 41 42 42 int ice_vsi_clear(struct ice_vsi *vsi); 43 43 44 + #ifdef CONFIG_DCB 45 + int ice_vsi_cfg_tc(struct ice_vsi *vsi, u8 ena_tc); 46 + #endif /* CONFIG_DCB */ 47 + 44 48 struct ice_vsi * 45 49 ice_vsi_setup(struct ice_pf *pf, struct ice_port_info *pi, 46 50 enum ice_vsi_type type, u16 vf_id); ··· 65 61 void ice_vsi_free_q_vectors(struct ice_vsi *vsi); 66 62 67 63 void ice_vsi_put_qs(struct ice_vsi *vsi); 64 + 65 + #ifdef CONFIG_DCB 66 + void ice_vsi_map_rings_to_vectors(struct ice_vsi *vsi); 67 + #endif /* CONFIG_DCB */ 68 68 69 69 void ice_vsi_dis_irq(struct ice_vsi *vsi); 70 70
+128 -90
drivers/net/ethernet/intel/ice/ice_main.c
··· 7 7 8 8 #include "ice.h" 9 9 #include "ice_lib.h" 10 + #include "ice_dcb_lib.h" 10 11 11 - #define DRV_VERSION "0.7.2-k" 12 + #define DRV_VERSION "0.7.4-k" 12 13 #define DRV_SUMMARY "Intel(R) Ethernet Connection E800 Series Linux Driver" 13 14 const char ice_drv_ver[] = DRV_VERSION; 14 15 static const char ice_driver_string[] = DRV_SUMMARY; ··· 31 30 static struct workqueue_struct *ice_wq; 32 31 static const struct net_device_ops ice_netdev_ops; 33 32 34 - static void ice_pf_dis_all_vsi(struct ice_pf *pf); 35 33 static void ice_rebuild(struct ice_pf *pf); 36 34 37 35 static void ice_vsi_release_all(struct ice_pf *pf); ··· 113 113 } 114 114 115 115 /** 116 - * ice_add_mac_to_sync_list - creates list of mac addresses to be synced 116 + * ice_add_mac_to_sync_list - creates list of MAC addresses to be synced 117 117 * @netdev: the net device on which the sync is happening 118 - * @addr: mac address to sync 118 + * @addr: MAC address to sync 119 119 * 120 120 * This is a callback function which is called by the in kernel device sync 121 121 * functions (like __dev_uc_sync, __dev_mc_sync, etc). This function only 122 122 * populates the tmp_sync_list, which is later used by ice_add_mac to add the 123 - * mac filters from the hardware. 123 + * MAC filters from the hardware. 124 124 */ 125 125 static int ice_add_mac_to_sync_list(struct net_device *netdev, const u8 *addr) 126 126 { ··· 134 134 } 135 135 136 136 /** 137 - * ice_add_mac_to_unsync_list - creates list of mac addresses to be unsynced 137 + * ice_add_mac_to_unsync_list - creates list of MAC addresses to be unsynced 138 138 * @netdev: the net device on which the unsync is happening 139 - * @addr: mac address to unsync 139 + * @addr: MAC address to unsync 140 140 * 141 141 * This is a callback function which is called by the in kernel device unsync 142 142 * functions (like __dev_uc_unsync, __dev_mc_unsync, etc). This function only 143 143 * populates the tmp_unsync_list, which is later used by ice_remove_mac to 144 - * delete the mac filters from the hardware. 144 + * delete the MAC filters from the hardware. 145 145 */ 146 146 static int ice_add_mac_to_unsync_list(struct net_device *netdev, const u8 *addr) 147 147 { ··· 245 245 netif_addr_unlock_bh(netdev); 246 246 } 247 247 248 - /* Remove mac addresses in the unsync list */ 248 + /* Remove MAC addresses in the unsync list */ 249 249 status = ice_remove_mac(hw, &vsi->tmp_unsync_list); 250 250 ice_free_fltr_list(dev, &vsi->tmp_unsync_list); 251 251 if (status) { ··· 257 257 } 258 258 } 259 259 260 - /* Add mac addresses in the sync list */ 260 + /* Add MAC addresses in the sync list */ 261 261 status = ice_add_mac(hw, &vsi->tmp_sync_list); 262 262 ice_free_fltr_list(dev, &vsi->tmp_sync_list); 263 263 /* If filter is added successfully or already exists, do not go into ··· 266 266 */ 267 267 if (status && status != ICE_ERR_ALREADY_EXISTS) { 268 268 netdev_err(netdev, "Failed to add MAC filters\n"); 269 - /* If there is no more space for new umac filters, vsi 269 + /* If there is no more space for new umac filters, VSI 270 270 * should go into promiscuous mode. There should be some 271 271 * space reserved for promiscuous filters. 272 272 */ ··· 317 317 test_bit(ICE_VSI_FLAG_PROMISC_CHANGED, vsi->flags)) { 318 318 clear_bit(ICE_VSI_FLAG_PROMISC_CHANGED, vsi->flags); 319 319 if (vsi->current_netdev_flags & IFF_PROMISC) { 320 - /* Apply TX filter rule to get traffic from VMs */ 320 + /* Apply Tx filter rule to get traffic from VMs */ 321 321 status = ice_cfg_dflt_vsi(hw, vsi->idx, true, 322 322 ICE_FLTR_TX); 323 323 if (status) { ··· 327 327 err = -EIO; 328 328 goto out_promisc; 329 329 } 330 - /* Apply RX filter rule to get traffic from wire */ 330 + /* Apply Rx filter rule to get traffic from wire */ 331 331 status = ice_cfg_dflt_vsi(hw, vsi->idx, true, 332 332 ICE_FLTR_RX); 333 333 if (status) { ··· 338 338 goto out_promisc; 339 339 } 340 340 } else { 341 - /* Clear TX filter rule to stop traffic from VMs */ 341 + /* Clear Tx filter rule to stop traffic from VMs */ 342 342 status = ice_cfg_dflt_vsi(hw, vsi->idx, false, 343 343 ICE_FLTR_TX); 344 344 if (status) { ··· 348 348 err = -EIO; 349 349 goto out_promisc; 350 350 } 351 - /* Clear RX filter to remove traffic from wire */ 351 + /* Clear Rx filter to remove traffic from wire */ 352 352 status = ice_cfg_dflt_vsi(hw, vsi->idx, false, 353 353 ICE_FLTR_RX); 354 354 if (status) { ··· 397 397 } 398 398 399 399 /** 400 + * ice_dis_vsi - pause a VSI 401 + * @vsi: the VSI being paused 402 + * @locked: is the rtnl_lock already held 403 + */ 404 + static void ice_dis_vsi(struct ice_vsi *vsi, bool locked) 405 + { 406 + if (test_bit(__ICE_DOWN, vsi->state)) 407 + return; 408 + 409 + set_bit(__ICE_NEEDS_RESTART, vsi->state); 410 + 411 + if (vsi->type == ICE_VSI_PF && vsi->netdev) { 412 + if (netif_running(vsi->netdev)) { 413 + if (!locked) { 414 + rtnl_lock(); 415 + vsi->netdev->netdev_ops->ndo_stop(vsi->netdev); 416 + rtnl_unlock(); 417 + } else { 418 + vsi->netdev->netdev_ops->ndo_stop(vsi->netdev); 419 + } 420 + } else { 421 + ice_vsi_close(vsi); 422 + } 423 + } 424 + } 425 + 426 + /** 427 + * ice_pf_dis_all_vsi - Pause all VSIs on a PF 428 + * @pf: the PF 429 + * @locked: is the rtnl_lock already held 430 + */ 431 + #ifdef CONFIG_DCB 432 + void ice_pf_dis_all_vsi(struct ice_pf *pf, bool locked) 433 + #else 434 + static void ice_pf_dis_all_vsi(struct ice_pf *pf, bool locked) 435 + #endif /* CONFIG_DCB */ 436 + { 437 + int v; 438 + 439 + ice_for_each_vsi(pf, v) 440 + if (pf->vsi[v]) 441 + ice_dis_vsi(pf->vsi[v], locked); 442 + } 443 + 444 + /** 400 445 * ice_prepare_for_reset - prep for the core to reset 401 446 * @pf: board private structure 402 447 * ··· 461 416 ice_vc_notify_reset(pf); 462 417 463 418 /* disable the VSIs and their queues that are not already DOWN */ 464 - ice_pf_dis_all_vsi(pf); 419 + ice_pf_dis_all_vsi(pf, false); 465 420 466 421 if (hw->port_info) 467 422 ice_sched_clear_port(hw->port_info); ··· 549 504 pf->hw.reset_ongoing = false; 550 505 ice_rebuild(pf); 551 506 /* clear bit to resume normal operations, but 552 - * ICE_NEEDS_RESTART bit is set incase rebuild failed 507 + * ICE_NEEDS_RESTART bit is set in case rebuild failed 553 508 */ 554 509 clear_bit(__ICE_RESET_OICR_RECV, pf->state); 555 510 clear_bit(__ICE_PREPARED_FOR_RESET, pf->state); ··· 653 608 } 654 609 655 610 /** 656 - * ice_vsi_link_event - update the vsi's netdev 657 - * @vsi: the vsi on which the link event occurred 658 - * @link_up: whether or not the vsi needs to be set up or down 611 + * ice_vsi_link_event - update the VSI's netdev 612 + * @vsi: the VSI on which the link event occurred 613 + * @link_up: whether or not the VSI needs to be set up or down 659 614 */ 660 615 static void ice_vsi_link_event(struct ice_vsi *vsi, bool link_up) 661 616 { ··· 935 890 break; 936 891 case ice_aqc_opc_fw_logging: 937 892 ice_output_fw_log(hw, &event.desc, event.msg_buf); 893 + break; 894 + case ice_aqc_opc_lldp_set_mib_change: 895 + ice_dcb_process_lldp_set_mib_change(pf, &event); 938 896 break; 939 897 default: 940 898 dev_dbg(&pf->pdev->dev, ··· 1284 1236 1285 1237 /** 1286 1238 * ice_set_ctrlq_len - helper function to set controlq length 1287 - * @hw: pointer to the hw instance 1239 + * @hw: pointer to the HW instance 1288 1240 */ 1289 1241 static void ice_set_ctrlq_len(struct ice_hw *hw) 1290 1242 { ··· 1844 1796 } 1845 1797 1846 1798 /** 1847 - * ice_vlan_rx_add_vid - Add a vlan id filter to HW offload 1799 + * ice_vlan_rx_add_vid - Add a VLAN ID filter to HW offload 1848 1800 * @netdev: network interface to be adjusted 1849 1801 * @proto: unused protocol 1850 - * @vid: vlan id to be added 1802 + * @vid: VLAN ID to be added 1851 1803 * 1852 - * net_device_ops implementation for adding vlan ids 1804 + * net_device_ops implementation for adding VLAN IDs 1853 1805 */ 1854 1806 static int 1855 1807 ice_vlan_rx_add_vid(struct net_device *netdev, __always_unused __be16 proto, ··· 1875 1827 return ret; 1876 1828 } 1877 1829 1878 - /* Add all VLAN ids including 0 to the switch filter. VLAN id 0 is 1830 + /* Add all VLAN IDs including 0 to the switch filter. VLAN ID 0 is 1879 1831 * needed to continue allowing all untagged packets since VLAN prune 1880 1832 * list is applied to all packets by the switch 1881 1833 */ ··· 1889 1841 } 1890 1842 1891 1843 /** 1892 - * ice_vlan_rx_kill_vid - Remove a vlan id filter from HW offload 1844 + * ice_vlan_rx_kill_vid - Remove a VLAN ID filter from HW offload 1893 1845 * @netdev: network interface to be adjusted 1894 1846 * @proto: unused protocol 1895 - * @vid: vlan id to be removed 1847 + * @vid: VLAN ID to be removed 1896 1848 * 1897 - * net_device_ops implementation for removing vlan ids 1849 + * net_device_ops implementation for removing VLAN IDs 1898 1850 */ 1899 1851 static int 1900 1852 ice_vlan_rx_kill_vid(struct net_device *netdev, __always_unused __be16 proto, ··· 2333 2285 2334 2286 ice_init_pf(pf); 2335 2287 2288 + err = ice_init_pf_dcb(pf); 2289 + if (err) { 2290 + clear_bit(ICE_FLAG_DCB_CAPABLE, pf->flags); 2291 + clear_bit(ICE_FLAG_DCB_ENA, pf->flags); 2292 + 2293 + /* do not fail overall init if DCB init fails */ 2294 + err = 0; 2295 + } 2296 + 2336 2297 ice_determine_q_usage(pf); 2337 2298 2338 2299 pf->num_alloc_vsi = hw->func_caps.guar_num_vsi; ··· 2679 2622 module_exit(ice_module_exit); 2680 2623 2681 2624 /** 2682 - * ice_set_mac_address - NDO callback to set mac address 2625 + * ice_set_mac_address - NDO callback to set MAC address 2683 2626 * @netdev: network interface device structure 2684 2627 * @pi: pointer to an address structure 2685 2628 * ··· 2716 2659 return -EBUSY; 2717 2660 } 2718 2661 2719 - /* When we change the mac address we also have to change the mac address 2720 - * based filter rules that were created previously for the old mac 2662 + /* When we change the MAC address we also have to change the MAC address 2663 + * based filter rules that were created previously for the old MAC 2721 2664 * address. So first, we remove the old filter rule using ice_remove_mac 2722 2665 * and then create a new filter rule using ice_add_mac. Note that for 2723 - * both these operations, we first need to form a "list" of mac 2724 - * addresses (even though in this case, we have only 1 mac address to be 2666 + * both these operations, we first need to form a "list" of MAC 2667 + * addresses (even though in this case, we have only 1 MAC address to be 2725 2668 * added/removed) and this done using ice_add_mac_to_list. Depending on 2726 - * the ensuing operation this "list" of mac addresses is either to be 2669 + * the ensuing operation this "list" of MAC addresses is either to be 2727 2670 * added or removed from the filter. 2728 2671 */ 2729 2672 err = ice_add_mac_to_list(vsi, &r_mac_list, netdev->dev_addr); ··· 2761 2704 return err; 2762 2705 } 2763 2706 2764 - /* change the netdev's mac address */ 2707 + /* change the netdev's MAC address */ 2765 2708 memcpy(netdev->dev_addr, mac, netdev->addr_len); 2766 2709 netdev_dbg(vsi->netdev, "updated mac address to %pM\n", 2767 2710 netdev->dev_addr); 2768 2711 2769 - /* write new mac address to the firmware */ 2712 + /* write new MAC address to the firmware */ 2770 2713 flags = ICE_AQC_MAN_MAC_UPDATE_LAA_WOL; 2771 2714 status = ice_aq_manage_mac_write(hw, mac, flags, NULL); 2772 2715 if (status) { ··· 2808 2751 * @tb: pointer to array of nladdr (unused) 2809 2752 * @dev: the net device pointer 2810 2753 * @addr: the MAC address entry being added 2811 - * @vid: VLAN id 2754 + * @vid: VLAN ID 2812 2755 * @flags: instructions from stack about fdb operation 2813 2756 * @extack: netlink extended ack 2814 2757 */ ··· 2848 2791 * @tb: pointer to array of nladdr (unused) 2849 2792 * @dev: the net device pointer 2850 2793 * @addr: the MAC address entry being added 2851 - * @vid: VLAN id 2794 + * @vid: VLAN ID 2852 2795 */ 2853 2796 static int 2854 2797 ice_fdb_del(struct ndmsg *ndm, __always_unused struct nlattr *tb[], ··· 2907 2850 } 2908 2851 2909 2852 /** 2910 - * ice_vsi_vlan_setup - Setup vlan offload properties on a VSI 2911 - * @vsi: VSI to setup vlan properties for 2853 + * ice_vsi_vlan_setup - Setup VLAN offload properties on a VSI 2854 + * @vsi: VSI to setup VLAN properties for 2912 2855 */ 2913 2856 static int ice_vsi_vlan_setup(struct ice_vsi *vsi) 2914 2857 { ··· 2940 2883 if (err) 2941 2884 return err; 2942 2885 } 2886 + ice_vsi_cfg_dcb_rings(vsi); 2943 2887 2944 2888 err = ice_vsi_cfg_lan_txqs(vsi); 2945 2889 if (!err) ··· 3250 3192 3251 3193 ice_stat_update32(hw, GLPRT_LXOFFTXC(pf_id), pf->stat_prev_loaded, 3252 3194 &prev_ps->link_xoff_tx, &cur_ps->link_xoff_tx); 3195 + 3196 + ice_update_dcb_stats(pf); 3253 3197 3254 3198 ice_stat_update32(hw, GLPRT_CRCERRS(pf_id), pf->stat_prev_loaded, 3255 3199 &prev_ps->crc_errors, &cur_ps->crc_errors); ··· 3631 3571 } 3632 3572 3633 3573 /** 3634 - * ice_dis_vsi - pause a VSI 3635 - * @vsi: the VSI being paused 3636 - * @locked: is the rtnl_lock already held 3637 - */ 3638 - static void ice_dis_vsi(struct ice_vsi *vsi, bool locked) 3639 - { 3640 - if (test_bit(__ICE_DOWN, vsi->state)) 3641 - return; 3642 - 3643 - set_bit(__ICE_NEEDS_RESTART, vsi->state); 3644 - 3645 - if (vsi->type == ICE_VSI_PF && vsi->netdev) { 3646 - if (netif_running(vsi->netdev)) { 3647 - if (!locked) { 3648 - rtnl_lock(); 3649 - vsi->netdev->netdev_ops->ndo_stop(vsi->netdev); 3650 - rtnl_unlock(); 3651 - } else { 3652 - vsi->netdev->netdev_ops->ndo_stop(vsi->netdev); 3653 - } 3654 - } else { 3655 - ice_vsi_close(vsi); 3656 - } 3657 - } 3658 - } 3659 - 3660 - /** 3661 3574 * ice_ena_vsi - resume a VSI 3662 3575 * @vsi: the VSI being resume 3576 + * @locked: is the rtnl_lock already held 3663 3577 */ 3664 - static int ice_ena_vsi(struct ice_vsi *vsi) 3578 + static int ice_ena_vsi(struct ice_vsi *vsi, bool locked) 3665 3579 { 3666 3580 int err = 0; 3667 3581 3668 - if (test_and_clear_bit(__ICE_NEEDS_RESTART, vsi->state) && 3669 - vsi->netdev) { 3582 + if (!test_bit(__ICE_NEEDS_RESTART, vsi->state)) 3583 + return err; 3584 + 3585 + clear_bit(__ICE_NEEDS_RESTART, vsi->state); 3586 + 3587 + if (vsi->netdev && vsi->type == ICE_VSI_PF) { 3588 + struct net_device *netd = vsi->netdev; 3589 + 3670 3590 if (netif_running(vsi->netdev)) { 3671 - rtnl_lock(); 3672 - err = vsi->netdev->netdev_ops->ndo_open(vsi->netdev); 3673 - rtnl_unlock(); 3591 + if (locked) { 3592 + err = netd->netdev_ops->ndo_open(netd); 3593 + } else { 3594 + rtnl_lock(); 3595 + err = netd->netdev_ops->ndo_open(netd); 3596 + rtnl_unlock(); 3597 + } 3674 3598 } else { 3675 3599 err = ice_vsi_open(vsi); 3676 3600 } ··· 3664 3620 } 3665 3621 3666 3622 /** 3667 - * ice_pf_dis_all_vsi - Pause all VSIs on a PF 3668 - * @pf: the PF 3669 - */ 3670 - static void ice_pf_dis_all_vsi(struct ice_pf *pf) 3671 - { 3672 - int v; 3673 - 3674 - ice_for_each_vsi(pf, v) 3675 - if (pf->vsi[v]) 3676 - ice_dis_vsi(pf->vsi[v], false); 3677 - } 3678 - 3679 - /** 3680 3623 * ice_pf_ena_all_vsi - Resume all VSIs on a PF 3681 3624 * @pf: the PF 3625 + * @locked: is the rtnl_lock already held 3682 3626 */ 3683 - static int ice_pf_ena_all_vsi(struct ice_pf *pf) 3627 + #ifdef CONFIG_DCB 3628 + int ice_pf_ena_all_vsi(struct ice_pf *pf, bool locked) 3629 + #else 3630 + static int ice_pf_ena_all_vsi(struct ice_pf *pf, bool locked) 3631 + #endif /* CONFIG_DCB */ 3684 3632 { 3685 3633 int v; 3686 3634 3687 3635 ice_for_each_vsi(pf, v) 3688 3636 if (pf->vsi[v]) 3689 - if (ice_ena_vsi(pf->vsi[v])) 3637 + if (ice_ena_vsi(pf->vsi[v], locked)) 3690 3638 return -EIO; 3691 3639 3692 3640 return 0; ··· 3793 3757 if (err) 3794 3758 goto err_sched_init_port; 3795 3759 3760 + ice_dcb_rebuild(pf); 3761 + 3796 3762 /* reset search_hint of irq_trackers to 0 since interrupts are 3797 3763 * reclaimed and could be allocated from beginning during VSI rebuild 3798 3764 */ ··· 3828 3790 } 3829 3791 3830 3792 /* restart the VSIs that were rebuilt and running before the reset */ 3831 - err = ice_pf_ena_all_vsi(pf); 3793 + err = ice_pf_ena_all_vsi(pf, false); 3832 3794 if (err) { 3833 3795 dev_err(&pf->pdev->dev, "error enabling VSIs\n"); 3834 3796 /* no need to disable VSIs in tear down path in ice_rebuild() ··· 4024 3986 /** 4025 3987 * ice_bridge_getlink - Get the hardware bridge mode 4026 3988 * @skb: skb buff 4027 - * @pid: process id 3989 + * @pid: process ID 4028 3990 * @seq: RTNL message seq 4029 3991 * @dev: the netdev being configured 4030 3992 * @filter_mask: filter mask passed in
+3 -3
drivers/net/ethernet/intel/ice/ice_nvm.c
··· 5 5 6 6 /** 7 7 * ice_aq_read_nvm 8 - * @hw: pointer to the hw struct 8 + * @hw: pointer to the HW struct 9 9 * @module_typeid: module pointer location in words from the NVM beginning 10 10 * @offset: byte offset from the module beginning 11 11 * @length: length of the section to be read (in bytes from the offset) ··· 235 235 236 236 /** 237 237 * ice_init_nvm - initializes NVM setting 238 - * @hw: pointer to the hw struct 238 + * @hw: pointer to the HW struct 239 239 * 240 240 * This function reads and populates NVM settings such as Shadow RAM size, 241 241 * max_timeout, and blank_nvm_mode ··· 248 248 u32 fla, gens_stat; 249 249 u8 sr_size; 250 250 251 - /* The SR size is stored regardless of the nvm programming mode 251 + /* The SR size is stored regardless of the NVM programming mode 252 252 * as the blank mode may be used in the factory line. 253 253 */ 254 254 gens_stat = rd32(hw, GLNVM_GENS);
+50 -75
drivers/net/ethernet/intel/ice/ice_sched.c
··· 43 43 /** 44 44 * ice_sched_find_node_by_teid - Find the Tx scheduler node in SW DB 45 45 * @start_node: pointer to the starting ice_sched_node struct in a sub-tree 46 - * @teid: node teid to search 46 + * @teid: node TEID to search 47 47 * 48 - * This function searches for a node matching the teid in the scheduling tree 48 + * This function searches for a node matching the TEID in the scheduling tree 49 49 * from the SW DB. The search is recursive and is restricted by the number of 50 50 * layers it has searched through; stopping at the max supported layer. 51 51 * ··· 66 66 start_node->info.data.elem_type == ICE_AQC_ELEM_TYPE_LEAF) 67 67 return NULL; 68 68 69 - /* Check if teid matches to any of the children nodes */ 69 + /* Check if TEID matches to any of the children nodes */ 70 70 for (i = 0; i < start_node->num_children; i++) 71 71 if (ICE_TXSCHED_GET_NODE_TEID(start_node->children[i]) == teid) 72 72 return start_node->children[i]; ··· 86 86 87 87 /** 88 88 * ice_aqc_send_sched_elem_cmd - send scheduling elements cmd 89 - * @hw: pointer to the hw struct 89 + * @hw: pointer to the HW struct 90 90 * @cmd_opc: cmd opcode 91 91 * @elems_req: number of elements to request 92 92 * @buf: pointer to buffer ··· 118 118 119 119 /** 120 120 * ice_aq_query_sched_elems - query scheduler elements 121 - * @hw: pointer to the hw struct 121 + * @hw: pointer to the HW struct 122 122 * @elems_req: number of elements to query 123 123 * @buf: pointer to buffer 124 124 * @buf_size: buffer size in bytes ··· 127 127 * 128 128 * Query scheduling elements (0x0404) 129 129 */ 130 - static enum ice_status 130 + enum ice_status 131 131 ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, 132 132 struct ice_aqc_get_elem *buf, u16 buf_size, 133 133 u16 *elems_ret, struct ice_sq_cd *cd) ··· 135 135 return ice_aqc_send_sched_elem_cmd(hw, ice_aqc_opc_get_sched_elems, 136 136 elems_req, (void *)buf, buf_size, 137 137 elems_ret, cd); 138 - } 139 - 140 - /** 141 - * ice_sched_query_elem - query element information from hw 142 - * @hw: pointer to the hw struct 143 - * @node_teid: node teid to be queried 144 - * @buf: buffer to element information 145 - * 146 - * This function queries HW element information 147 - */ 148 - static enum ice_status 149 - ice_sched_query_elem(struct ice_hw *hw, u32 node_teid, 150 - struct ice_aqc_get_elem *buf) 151 - { 152 - u16 buf_size, num_elem_ret = 0; 153 - enum ice_status status; 154 - 155 - buf_size = sizeof(*buf); 156 - memset(buf, 0, buf_size); 157 - buf->generic[0].node_teid = cpu_to_le32(node_teid); 158 - status = ice_aq_query_sched_elems(hw, 1, buf, buf_size, &num_elem_ret, 159 - NULL); 160 - if (status || num_elem_ret != 1) 161 - ice_debug(hw, ICE_DBG_SCHED, "query element failed\n"); 162 - return status; 163 138 } 164 139 165 140 /** ··· 201 226 202 227 /** 203 228 * ice_aq_delete_sched_elems - delete scheduler elements 204 - * @hw: pointer to the hw struct 229 + * @hw: pointer to the HW struct 205 230 * @grps_req: number of groups to delete 206 231 * @buf: pointer to buffer 207 232 * @buf_size: buffer size in bytes ··· 221 246 } 222 247 223 248 /** 224 - * ice_sched_remove_elems - remove nodes from hw 225 - * @hw: pointer to the hw struct 249 + * ice_sched_remove_elems - remove nodes from HW 250 + * @hw: pointer to the HW struct 226 251 * @parent: pointer to the parent node 227 252 * @num_nodes: number of nodes 228 253 * @node_teids: array of node teids to be deleted 229 254 * 230 - * This function remove nodes from hw 255 + * This function remove nodes from HW 231 256 */ 232 257 static enum ice_status 233 258 ice_sched_remove_elems(struct ice_hw *hw, struct ice_sched_node *parent, ··· 260 285 261 286 /** 262 287 * ice_sched_get_first_node - get the first node of the given layer 263 - * @hw: pointer to the hw struct 288 + * @hw: pointer to the HW struct 264 289 * @parent: pointer the base node of the subtree 265 290 * @layer: layer number 266 291 * ··· 381 406 382 407 /** 383 408 * ice_aq_get_dflt_topo - gets default scheduler topology 384 - * @hw: pointer to the hw struct 409 + * @hw: pointer to the HW struct 385 410 * @lport: logical port number 386 411 * @buf: pointer to buffer 387 412 * @buf_size: buffer size in bytes ··· 411 436 412 437 /** 413 438 * ice_aq_add_sched_elems - adds scheduling element 414 - * @hw: pointer to the hw struct 439 + * @hw: pointer to the HW struct 415 440 * @grps_req: the number of groups that are requested to be added 416 441 * @buf: pointer to buffer 417 442 * @buf_size: buffer size in bytes ··· 432 457 433 458 /** 434 459 * ice_aq_suspend_sched_elems - suspend scheduler elements 435 - * @hw: pointer to the hw struct 460 + * @hw: pointer to the HW struct 436 461 * @elems_req: number of elements to suspend 437 462 * @buf: pointer to buffer 438 463 * @buf_size: buffer size in bytes ··· 453 478 454 479 /** 455 480 * ice_aq_resume_sched_elems - resume scheduler elements 456 - * @hw: pointer to the hw struct 481 + * @hw: pointer to the HW struct 457 482 * @elems_req: number of elements to resume 458 483 * @buf: pointer to buffer 459 484 * @buf_size: buffer size in bytes ··· 474 499 475 500 /** 476 501 * ice_aq_query_sched_res - query scheduler resource 477 - * @hw: pointer to the hw struct 502 + * @hw: pointer to the HW struct 478 503 * @buf_size: buffer size in bytes 479 504 * @buf: pointer to buffer 480 505 * @cd: pointer to command details structure or NULL ··· 493 518 } 494 519 495 520 /** 496 - * ice_sched_suspend_resume_elems - suspend or resume hw nodes 497 - * @hw: pointer to the hw struct 521 + * ice_sched_suspend_resume_elems - suspend or resume HW nodes 522 + * @hw: pointer to the HW struct 498 523 * @num_nodes: number of nodes 499 524 * @node_teids: array of node teids to be suspended or resumed 500 525 * @suspend: true means suspend / false means resume 501 526 * 502 - * This function suspends or resumes hw nodes 527 + * This function suspends or resumes HW nodes 503 528 */ 504 529 static enum ice_status 505 530 ice_sched_suspend_resume_elems(struct ice_hw *hw, u8 num_nodes, u32 *node_teids, ··· 533 558 } 534 559 535 560 /** 536 - * ice_sched_clear_agg - clears the agg related information 561 + * ice_sched_clear_agg - clears the aggregator related information 537 562 * @hw: pointer to the hardware structure 538 563 * 539 - * This function removes agg list and free up agg related memory 564 + * This function removes aggregator list and free up aggregator related memory 540 565 * previously allocated. 541 566 */ 542 567 void ice_sched_clear_agg(struct ice_hw *hw) ··· 594 619 595 620 /** 596 621 * ice_sched_cleanup_all - cleanup scheduler elements from SW DB for all ports 597 - * @hw: pointer to the hw struct 622 + * @hw: pointer to the HW struct 598 623 * 599 624 * Cleanup scheduling elements from SW DB for all the ports 600 625 */ ··· 618 643 } 619 644 620 645 /** 621 - * ice_sched_add_elems - add nodes to hw and SW DB 646 + * ice_sched_add_elems - add nodes to HW and SW DB 622 647 * @pi: port information structure 623 648 * @tc_node: pointer to the branch node 624 649 * @parent: pointer to the parent node 625 650 * @layer: layer number to add nodes 626 651 * @num_nodes: number of nodes 627 652 * @num_nodes_added: pointer to num nodes added 628 - * @first_node_teid: if new nodes are added then return the teid of first node 653 + * @first_node_teid: if new nodes are added then return the TEID of first node 629 654 * 630 - * This function add nodes to hw as well as to SW DB for a given layer 655 + * This function add nodes to HW as well as to SW DB for a given layer 631 656 */ 632 657 static enum ice_status 633 658 ice_sched_add_elems(struct ice_port_info *pi, struct ice_sched_node *tc_node, ··· 721 746 * @parent: pointer to parent node 722 747 * @layer: layer number to add nodes 723 748 * @num_nodes: number of nodes to be added 724 - * @first_node_teid: pointer to the first node teid 749 + * @first_node_teid: pointer to the first node TEID 725 750 * @num_nodes_added: pointer to number of nodes added 726 751 * 727 752 * This function add nodes to a given layer. ··· 773 798 774 799 *num_nodes_added += num_added; 775 800 } 776 - /* Don't modify the first node teid memory if the first node was 801 + /* Don't modify the first node TEID memory if the first node was 777 802 * added already in the above call. Instead send some temp 778 803 * memory for all other recursive calls. 779 804 */ ··· 805 830 806 831 /** 807 832 * ice_sched_get_qgrp_layer - get the current queue group layer number 808 - * @hw: pointer to the hw struct 833 + * @hw: pointer to the HW struct 809 834 * 810 835 * This function returns the current queue group layer number 811 836 */ ··· 817 842 818 843 /** 819 844 * ice_sched_get_vsi_layer - get the current VSI layer number 820 - * @hw: pointer to the hw struct 845 + * @hw: pointer to the HW struct 821 846 * 822 847 * This function returns the current VSI layer number 823 848 */ ··· 828 853 * 7 4 829 854 * 5 or less sw_entry_point_layer 830 855 */ 831 - /* calculate the vsi layer based on number of layers. */ 856 + /* calculate the VSI layer based on number of layers. */ 832 857 if (hw->num_tx_sched_layers > ICE_VSI_LAYER_OFFSET + 1) { 833 858 u8 layer = hw->num_tx_sched_layers - ICE_VSI_LAYER_OFFSET; 834 859 ··· 946 971 goto err_init_port; 947 972 } 948 973 949 - /* If the last node is a leaf node then the index of the Q group 974 + /* If the last node is a leaf node then the index of the queue group 950 975 * layer is two less than the number of elements. 951 976 */ 952 977 if (num_elems > 2 && buf[0].generic[num_elems - 1].data.elem_type == ··· 1055 1080 1056 1081 /** 1057 1082 * ice_sched_find_node_in_subtree - Find node in part of base node subtree 1058 - * @hw: pointer to the hw struct 1083 + * @hw: pointer to the HW struct 1059 1084 * @base: pointer to the base node 1060 1085 * @node: pointer to the node to search 1061 1086 * ··· 1087 1112 } 1088 1113 1089 1114 /** 1090 - * ice_sched_get_free_qparent - Get a free lan or rdma q group node 1115 + * ice_sched_get_free_qparent - Get a free LAN or RDMA queue group node 1091 1116 * @pi: port information structure 1092 1117 * @vsi_handle: software VSI handle 1093 1118 * @tc: branch number 1094 - * @owner: lan or rdma 1119 + * @owner: LAN or RDMA 1095 1120 * 1096 - * This function retrieves a free lan or rdma q group node 1121 + * This function retrieves a free LAN or RDMA queue group node 1097 1122 */ 1098 1123 struct ice_sched_node * 1099 1124 ice_sched_get_free_qparent(struct ice_port_info *pi, u16 vsi_handle, u8 tc, ··· 1111 1136 if (!vsi_ctx) 1112 1137 return NULL; 1113 1138 vsi_node = vsi_ctx->sched.vsi_node[tc]; 1114 - /* validate invalid VSI id */ 1139 + /* validate invalid VSI ID */ 1115 1140 if (!vsi_node) 1116 1141 goto lan_q_exit; 1117 1142 1118 - /* get the first q group node from VSI sub-tree */ 1143 + /* get the first queue group node from VSI sub-tree */ 1119 1144 qgrp_node = ice_sched_get_first_node(pi->hw, vsi_node, qgrp_layer); 1120 1145 while (qgrp_node) { 1121 1146 /* make sure the qgroup node is part of the VSI subtree */ ··· 1131 1156 } 1132 1157 1133 1158 /** 1134 - * ice_sched_get_vsi_node - Get a VSI node based on VSI id 1135 - * @hw: pointer to the hw struct 1159 + * ice_sched_get_vsi_node - Get a VSI node based on VSI ID 1160 + * @hw: pointer to the HW struct 1136 1161 * @tc_node: pointer to the TC node 1137 1162 * @vsi_handle: software VSI handle 1138 1163 * 1139 - * This function retrieves a VSI node for a given VSI id from a given 1164 + * This function retrieves a VSI node for a given VSI ID from a given 1140 1165 * TC branch 1141 1166 */ 1142 1167 static struct ice_sched_node * ··· 1161 1186 1162 1187 /** 1163 1188 * ice_sched_calc_vsi_child_nodes - calculate number of VSI child nodes 1164 - * @hw: pointer to the hw struct 1189 + * @hw: pointer to the HW struct 1165 1190 * @num_qs: number of queues 1166 1191 * @num_nodes: num nodes array 1167 1192 * ··· 1177 1202 qgl = ice_sched_get_qgrp_layer(hw); 1178 1203 vsil = ice_sched_get_vsi_layer(hw); 1179 1204 1180 - /* calculate num nodes from q group to VSI layer */ 1205 + /* calculate num nodes from queue group to VSI layer */ 1181 1206 for (i = qgl; i > vsil; i--) { 1182 1207 /* round to the next integer if there is a remainder */ 1183 1208 num = DIV_ROUND_UP(num, hw->max_children[i]); ··· 1193 1218 * @vsi_handle: software VSI handle 1194 1219 * @tc_node: pointer to the TC node 1195 1220 * @num_nodes: pointer to the num nodes that needs to be added per layer 1196 - * @owner: node owner (lan or rdma) 1221 + * @owner: node owner (LAN or RDMA) 1197 1222 * 1198 1223 * This function adds the VSI child nodes to tree. It gets called for 1199 - * lan and rdma separately. 1224 + * LAN and RDMA separately. 1200 1225 */ 1201 1226 static enum ice_status 1202 1227 ice_sched_add_vsi_child_nodes(struct ice_port_info *pi, u16 vsi_handle, ··· 1245 1270 1246 1271 /** 1247 1272 * ice_sched_calc_vsi_support_nodes - calculate number of VSI support nodes 1248 - * @hw: pointer to the hw struct 1273 + * @hw: pointer to the HW struct 1249 1274 * @tc_node: pointer to TC node 1250 1275 * @num_nodes: pointer to num nodes array 1251 1276 * ··· 1364 1389 /* calculate number of supported nodes needed for this VSI */ 1365 1390 ice_sched_calc_vsi_support_nodes(hw, tc_node, num_nodes); 1366 1391 1367 - /* add vsi supported nodes to tc subtree */ 1392 + /* add VSI supported nodes to TC subtree */ 1368 1393 return ice_sched_add_vsi_support_nodes(pi, vsi_handle, tc_node, 1369 1394 num_nodes); 1370 1395 } ··· 1435 1460 * @vsi_handle: software VSI handle 1436 1461 * @tc: TC number 1437 1462 * @maxqs: max number of queues 1438 - * @owner: lan or rdma 1463 + * @owner: LAN or RDMA 1439 1464 * @enable: TC enabled or disabled 1440 1465 * 1441 1466 * This function adds/updates VSI nodes based on the number of queues. If TC is ··· 1460 1485 return ICE_ERR_PARAM; 1461 1486 vsi_node = ice_sched_get_vsi_node(hw, tc_node, vsi_handle); 1462 1487 1463 - /* suspend the VSI if tc is not enabled */ 1488 + /* suspend the VSI if TC is not enabled */ 1464 1489 if (!enable) { 1465 1490 if (vsi_node && vsi_node->in_use) { 1466 1491 u32 teid = le32_to_cpu(vsi_node->info.node_teid); ··· 1511 1536 } 1512 1537 1513 1538 /** 1514 - * ice_sched_rm_agg_vsi_entry - remove agg related VSI info entry 1539 + * ice_sched_rm_agg_vsi_entry - remove aggregator related VSI info entry 1515 1540 * @pi: port information structure 1516 1541 * @vsi_handle: software VSI handle 1517 1542 * ··· 1616 1641 ice_free_sched_node(pi, vsi_node); 1617 1642 vsi_ctx->sched.vsi_node[i] = NULL; 1618 1643 1619 - /* clean up agg related vsi info if any */ 1644 + /* clean up aggregator related VSI info if any */ 1620 1645 ice_sched_rm_agg_vsi_info(pi, vsi_handle); 1621 1646 } 1622 1647 if (owner == ICE_SCHED_NODE_OWNER_LAN)
+4
drivers/net/ethernet/intel/ice/ice_sched.h
··· 24 24 }; 25 25 26 26 /* FW AQ command calls */ 27 + enum ice_status 28 + ice_aq_query_sched_elems(struct ice_hw *hw, u16 elems_req, 29 + struct ice_aqc_get_elem *buf, u16 buf_size, 30 + u16 *elems_ret, struct ice_sq_cd *cd); 27 31 enum ice_status ice_sched_init_port(struct ice_port_info *pi); 28 32 enum ice_status ice_sched_query_res_alloc(struct ice_hw *hw); 29 33 void ice_sched_clear_port(struct ice_port_info *pi);
+1
drivers/net/ethernet/intel/ice/ice_status.h
··· 12 12 ICE_ERR_PARAM = -1, 13 13 ICE_ERR_NOT_IMPL = -2, 14 14 ICE_ERR_NOT_READY = -3, 15 + ICE_ERR_NOT_SUPPORTED = -4, 15 16 ICE_ERR_BAD_PTR = -5, 16 17 ICE_ERR_INVAL_SIZE = -6, 17 18 ICE_ERR_DEVICE_NOT_SUPPORTED = -8,
+54 -54
drivers/net/ethernet/intel/ice/ice_switch.c
··· 19 19 * byte 6 = 0x2: to identify it as locally administered SA MAC 20 20 * byte 12 = 0x81 & byte 13 = 0x00: 21 21 * In case of VLAN filter first two bytes defines ether type (0x8100) 22 - * and remaining two bytes are placeholder for programming a given VLAN id 22 + * and remaining two bytes are placeholder for programming a given VLAN ID 23 23 * In case of Ether type filter it is treated as header without VLAN tag 24 24 * and byte 12 and 13 is used to program a given Ether type instead 25 25 */ ··· 51 51 52 52 /** 53 53 * ice_aq_alloc_free_res - command to allocate/free resources 54 - * @hw: pointer to the hw struct 54 + * @hw: pointer to the HW struct 55 55 * @num_entries: number of resource entries in buffer 56 56 * @buf: Indirect buffer to hold data parameters and response 57 57 * @buf_size: size of buffer for indirect commands ··· 87 87 88 88 /** 89 89 * ice_init_def_sw_recp - initialize the recipe book keeping tables 90 - * @hw: pointer to the hw struct 90 + * @hw: pointer to the HW struct 91 91 * 92 92 * Allocate memory for the entire recipe table and initialize the structures/ 93 93 * entries corresponding to basic recipes. ··· 163 163 164 164 /** 165 165 * ice_aq_add_vsi 166 - * @hw: pointer to the hw struct 166 + * @hw: pointer to the HW struct 167 167 * @vsi_ctx: pointer to a VSI context struct 168 168 * @cd: pointer to command details structure or NULL 169 169 * ··· 206 206 207 207 /** 208 208 * ice_aq_free_vsi 209 - * @hw: pointer to the hw struct 209 + * @hw: pointer to the HW struct 210 210 * @vsi_ctx: pointer to a VSI context struct 211 211 * @keep_vsi_alloc: keep VSI allocation as part of this PF's resources 212 212 * @cd: pointer to command details structure or NULL ··· 242 242 243 243 /** 244 244 * ice_aq_update_vsi 245 - * @hw: pointer to the hw struct 245 + * @hw: pointer to the HW struct 246 246 * @vsi_ctx: pointer to a VSI context struct 247 247 * @cd: pointer to command details structure or NULL 248 248 * ··· 279 279 280 280 /** 281 281 * ice_is_vsi_valid - check whether the VSI is valid or not 282 - * @hw: pointer to the hw struct 282 + * @hw: pointer to the HW struct 283 283 * @vsi_handle: VSI handle 284 284 * 285 285 * check whether the VSI is valid or not ··· 290 290 } 291 291 292 292 /** 293 - * ice_get_hw_vsi_num - return the hw VSI number 294 - * @hw: pointer to the hw struct 293 + * ice_get_hw_vsi_num - return the HW VSI number 294 + * @hw: pointer to the HW struct 295 295 * @vsi_handle: VSI handle 296 296 * 297 - * return the hw VSI number 297 + * return the HW VSI number 298 298 * Caution: call this function only if VSI is valid (ice_is_vsi_valid) 299 299 */ 300 300 u16 ice_get_hw_vsi_num(struct ice_hw *hw, u16 vsi_handle) ··· 304 304 305 305 /** 306 306 * ice_get_vsi_ctx - return the VSI context entry for a given VSI handle 307 - * @hw: pointer to the hw struct 307 + * @hw: pointer to the HW struct 308 308 * @vsi_handle: VSI handle 309 309 * 310 310 * return the VSI context entry for a given VSI handle ··· 316 316 317 317 /** 318 318 * ice_save_vsi_ctx - save the VSI context for a given VSI handle 319 - * @hw: pointer to the hw struct 319 + * @hw: pointer to the HW struct 320 320 * @vsi_handle: VSI handle 321 321 * @vsi: VSI context pointer 322 322 * ··· 330 330 331 331 /** 332 332 * ice_clear_vsi_ctx - clear the VSI context entry 333 - * @hw: pointer to the hw struct 333 + * @hw: pointer to the HW struct 334 334 * @vsi_handle: VSI handle 335 335 * 336 336 * clear the VSI context entry ··· 348 348 349 349 /** 350 350 * ice_clear_all_vsi_ctx - clear all the VSI context entries 351 - * @hw: pointer to the hw struct 351 + * @hw: pointer to the HW struct 352 352 */ 353 353 void ice_clear_all_vsi_ctx(struct ice_hw *hw) 354 354 { ··· 360 360 361 361 /** 362 362 * ice_add_vsi - add VSI context to the hardware and VSI handle list 363 - * @hw: pointer to the hw struct 363 + * @hw: pointer to the HW struct 364 364 * @vsi_handle: unique VSI handle provided by drivers 365 365 * @vsi_ctx: pointer to a VSI context struct 366 366 * @cd: pointer to command details structure or NULL ··· 383 383 return status; 384 384 tmp_vsi_ctx = ice_get_vsi_ctx(hw, vsi_handle); 385 385 if (!tmp_vsi_ctx) { 386 - /* Create a new vsi context */ 386 + /* Create a new VSI context */ 387 387 tmp_vsi_ctx = devm_kzalloc(ice_hw_to_dev(hw), 388 388 sizeof(*tmp_vsi_ctx), GFP_KERNEL); 389 389 if (!tmp_vsi_ctx) { ··· 403 403 404 404 /** 405 405 * ice_free_vsi- free VSI context from hardware and VSI handle list 406 - * @hw: pointer to the hw struct 406 + * @hw: pointer to the HW struct 407 407 * @vsi_handle: unique VSI handle 408 408 * @vsi_ctx: pointer to a VSI context struct 409 409 * @keep_vsi_alloc: keep VSI allocation as part of this PF's resources ··· 428 428 429 429 /** 430 430 * ice_update_vsi 431 - * @hw: pointer to the hw struct 431 + * @hw: pointer to the HW struct 432 432 * @vsi_handle: unique VSI handle 433 433 * @vsi_ctx: pointer to a VSI context struct 434 434 * @cd: pointer to command details structure or NULL ··· 447 447 448 448 /** 449 449 * ice_aq_alloc_free_vsi_list 450 - * @hw: pointer to the hw struct 451 - * @vsi_list_id: VSI list id returned or used for lookup 450 + * @hw: pointer to the HW struct 451 + * @vsi_list_id: VSI list ID returned or used for lookup 452 452 * @lkup_type: switch rule filter lookup type 453 453 * @opc: switch rules population command type - pass in the command opcode 454 454 * ··· 504 504 505 505 /** 506 506 * ice_aq_sw_rules - add/update/remove switch rules 507 - * @hw: pointer to the hw struct 507 + * @hw: pointer to the HW struct 508 508 * @rule_list: pointer to switch rule population list 509 509 * @rule_list_sz: total size of the rule list in bytes 510 510 * @num_rules: number of switch rules in the rule_list ··· 653 653 * 1. The switch is a VEB AND 654 654 * 2 655 655 * 2.1 The lookup is a directional lookup like ethertype, 656 - * promiscuous, ethertype-mac, promiscuous-vlan 656 + * promiscuous, ethertype-MAC, promiscuous-VLAN 657 657 * and default-port OR 658 658 * 2.2 The lookup is VLAN, OR 659 659 * 2.3 The lookup is MAC with mcast or bcast addr for MAC, OR ··· 821 821 * @hw: pointer to the hardware structure 822 822 * @m_ent: the management entry for which sw marker needs to be added 823 823 * @sw_marker: sw marker to tag the Rx descriptor with 824 - * @l_id: large action resource id 824 + * @l_id: large action resource ID 825 825 * 826 826 * Create a large action to hold software marker and update the switch rule 827 827 * entry pointed by m_ent with newly created large action ··· 833 833 struct ice_aqc_sw_rules_elem *lg_act, *rx_tx; 834 834 /* For software marker we need 3 large actions 835 835 * 1. FWD action: FWD TO VSI or VSI LIST 836 - * 2. GENERIC VALUE action to hold the profile id 837 - * 3. GENERIC VALUE action to hold the software marker id 836 + * 2. GENERIC VALUE action to hold the profile ID 837 + * 3. GENERIC VALUE action to hold the software marker ID 838 838 */ 839 839 const u16 num_lg_acts = 3; 840 840 enum ice_status status; ··· 897 897 ice_fill_sw_rule(hw, &m_ent->fltr_info, rx_tx, 898 898 ice_aqc_opc_update_sw_rules); 899 899 900 - /* Update the action to point to the large action id */ 900 + /* Update the action to point to the large action ID */ 901 901 rx_tx->pdata.lkup_tx_rx.act = 902 902 cpu_to_le32(ICE_SINGLE_ACT_PTR | 903 903 ((l_id << ICE_SINGLE_ACT_PTR_VAL_S) & 904 904 ICE_SINGLE_ACT_PTR_VAL_M)); 905 905 906 - /* Use the filter rule id of the previously created rule with single 906 + /* Use the filter rule ID of the previously created rule with single 907 907 * act. Once the update happens, hardware will treat this as large 908 908 * action 909 909 */ ··· 926 926 * @hw: pointer to the hardware structure 927 927 * @vsi_handle_arr: array of VSI handles to set in the VSI mapping 928 928 * @num_vsi: number of VSI handles in the array 929 - * @vsi_list_id: VSI list id generated as part of allocate resource 929 + * @vsi_list_id: VSI list ID generated as part of allocate resource 930 930 * 931 - * Helper function to create a new entry of VSI list id to VSI mapping 932 - * using the given VSI list id 931 + * Helper function to create a new entry of VSI list ID to VSI mapping 932 + * using the given VSI list ID 933 933 */ 934 934 static struct ice_vsi_list_map_info * 935 935 ice_create_vsi_list_map(struct ice_hw *hw, u16 *vsi_handle_arr, u16 num_vsi, ··· 957 957 * @hw: pointer to the hardware structure 958 958 * @vsi_handle_arr: array of VSI handles to form a VSI list 959 959 * @num_vsi: number of VSI handles in the array 960 - * @vsi_list_id: VSI list id generated as part of allocate resource 960 + * @vsi_list_id: VSI list ID generated as part of allocate resource 961 961 * @remove: Boolean value to indicate if this is a remove action 962 962 * @opc: switch rules population command type - pass in the command opcode 963 963 * @lkup_type: lookup type of the filter 964 964 * 965 965 * Call AQ command to add a new switch rule or update existing switch rule 966 - * using the given VSI list id 966 + * using the given VSI list ID 967 967 */ 968 968 static enum ice_status 969 969 ice_update_vsi_list_rule(struct ice_hw *hw, u16 *vsi_handle_arr, u16 num_vsi, ··· 1020 1020 1021 1021 /** 1022 1022 * ice_create_vsi_list_rule - Creates and populates a VSI list rule 1023 - * @hw: pointer to the hw struct 1023 + * @hw: pointer to the HW struct 1024 1024 * @vsi_handle_arr: array of VSI handles to form a VSI list 1025 1025 * @num_vsi: number of VSI handles in the array 1026 1026 * @vsi_list_id: stores the ID of the VSI list to be created ··· 1114 1114 * @f_info: filter information for switch rule 1115 1115 * 1116 1116 * Call AQ command to update a previously created switch rule with a 1117 - * VSI list id 1117 + * VSI list ID 1118 1118 */ 1119 1119 static enum ice_status 1120 1120 ice_update_pkt_fwd_rule(struct ice_hw *hw, struct ice_fltr_info *f_info) ··· 1141 1141 1142 1142 /** 1143 1143 * ice_update_sw_rule_bridge_mode 1144 - * @hw: pointer to the hw struct 1144 + * @hw: pointer to the HW struct 1145 1145 * 1146 1146 * Updates unicast switch filter rules based on VEB/VEPA mode 1147 1147 */ ··· 1196 1196 * Allocate a new VSI list and add two VSIs 1197 1197 * to this list using switch rule command 1198 1198 * Update the previously created switch rule with the 1199 - * newly created VSI list id 1199 + * newly created VSI list ID 1200 1200 * if a VSI list was previously created 1201 1201 * Add the new VSI to the previously created VSI list set 1202 1202 * using the update switch rule command ··· 1277 1277 return 0; 1278 1278 1279 1279 /* Update the previously created VSI list set with 1280 - * the new VSI id passed in 1280 + * the new VSI ID passed in 1281 1281 */ 1282 1282 vsi_list_id = cur_fltr->fwd_id.vsi_list_id; 1283 1283 opcode = ice_aqc_opc_update_sw_rules; ··· 1285 1285 status = ice_update_vsi_list_rule(hw, &vsi_handle, 1, 1286 1286 vsi_list_id, false, opcode, 1287 1287 new_fltr->lkup_type); 1288 - /* update VSI list mapping info with new VSI id */ 1288 + /* update VSI list mapping info with new VSI ID */ 1289 1289 if (!status) 1290 1290 set_bit(vsi_handle, m_entry->vsi_list_info->vsi_map); 1291 1291 } ··· 1327 1327 * @hw: pointer to the hardware structure 1328 1328 * @recp_id: lookup type for which VSI lists needs to be searched 1329 1329 * @vsi_handle: VSI handle to be found in VSI list 1330 - * @vsi_list_id: VSI list id found containing vsi_handle 1330 + * @vsi_list_id: VSI list ID found containing vsi_handle 1331 1331 * 1332 1332 * Helper function to search a VSI list with single entry containing given VSI 1333 1333 * handle element. This can be extended further to search VSI list with more ··· 1358 1358 /** 1359 1359 * ice_add_rule_internal - add rule for a given lookup type 1360 1360 * @hw: pointer to the hardware structure 1361 - * @recp_id: lookup type (recipe id) for which rule has to be added 1361 + * @recp_id: lookup type (recipe ID) for which rule has to be added 1362 1362 * @f_entry: structure containing MAC forwarding information 1363 1363 * 1364 1364 * Adds or updates the rule lists for a given recipe ··· 1403 1403 /** 1404 1404 * ice_remove_vsi_list_rule 1405 1405 * @hw: pointer to the hardware structure 1406 - * @vsi_list_id: VSI list id generated as part of allocate resource 1406 + * @vsi_list_id: VSI list ID generated as part of allocate resource 1407 1407 * @lkup_type: switch rule filter lookup type 1408 1408 * 1409 1409 * The VSI list should be emptied before this function is called to remove the ··· 1528 1528 /** 1529 1529 * ice_remove_rule_internal - Remove a filter rule of a given type 1530 1530 * @hw: pointer to the hardware structure 1531 - * @recp_id: recipe id for which the rule needs to removed 1531 + * @recp_id: recipe ID for which the rule needs to removed 1532 1532 * @f_entry: rule entry containing filter information 1533 1533 */ 1534 1534 static enum ice_status ··· 1578 1578 status = ice_rem_update_vsi_list(hw, vsi_handle, list_elem); 1579 1579 if (status) 1580 1580 goto exit; 1581 - /* if vsi count goes to zero after updating the vsi list */ 1581 + /* if VSI count goes to zero after updating the VSI list */ 1582 1582 if (list_elem->vsi_count == 0) 1583 1583 remove_rule = true; 1584 1584 } ··· 1656 1656 return ICE_ERR_PARAM; 1657 1657 hw_vsi_id = ice_get_hw_vsi_num(hw, vsi_handle); 1658 1658 m_list_itr->fltr_info.fwd_id.hw_vsi_id = hw_vsi_id; 1659 - /* update the src in case it is vsi num */ 1659 + /* update the src in case it is VSI num */ 1660 1660 if (m_list_itr->fltr_info.src_id != ICE_SRC_ID_VSI) 1661 1661 return ICE_ERR_PARAM; 1662 1662 m_list_itr->fltr_info.src = hw_vsi_id; ··· 1732 1732 ((u8 *)r_iter + (elem_sent * s_rule_size)); 1733 1733 } 1734 1734 1735 - /* Fill up rule id based on the value returned from FW */ 1735 + /* Fill up rule ID based on the value returned from FW */ 1736 1736 r_iter = s_rule; 1737 1737 list_for_each_entry(m_list_itr, m_list, list_entry) { 1738 1738 struct ice_fltr_info *f_info = &m_list_itr->fltr_info; ··· 1792 1792 ice_get_hw_vsi_num(hw, f_entry->fltr_info.vsi_handle); 1793 1793 new_fltr = &f_entry->fltr_info; 1794 1794 1795 - /* VLAN id should only be 12 bits */ 1795 + /* VLAN ID should only be 12 bits */ 1796 1796 if (new_fltr->l_data.vlan.vlan_id > ICE_MAX_VLAN_ID) 1797 1797 return ICE_ERR_PARAM; 1798 1798 ··· 1850 1850 } 1851 1851 } 1852 1852 } else if (v_list_itr->vsi_list_info->ref_cnt == 1) { 1853 - /* Update existing VSI list to add new VSI id only if it used 1853 + /* Update existing VSI list to add new VSI ID only if it used 1854 1854 * by one VLAN rule. 1855 1855 */ 1856 1856 cur_fltr = &v_list_itr->fltr_info; ··· 1860 1860 /* If VLAN rule exists and VSI list being used by this rule is 1861 1861 * referenced by more than 1 VLAN rule. Then create a new VSI 1862 1862 * list appending previous VSI with new VSI and update existing 1863 - * VLAN rule to point to new VSI list id 1863 + * VLAN rule to point to new VSI list ID 1864 1864 */ 1865 1865 struct ice_fltr_info tmp_fltr; 1866 1866 u16 vsi_handle_arr[2]; ··· 2192 2192 struct ice_fltr_mgmt_list_entry *fm_entry; 2193 2193 enum ice_status status = 0; 2194 2194 2195 - /* check to make sure VSI id is valid and within boundary */ 2195 + /* check to make sure VSI ID is valid and within boundary */ 2196 2196 if (!ice_is_vsi_valid(hw, vsi_handle)) 2197 2197 return ICE_ERR_PARAM; 2198 2198 ··· 2247 2247 /** 2248 2248 * ice_remove_promisc - Remove promisc based filter rules 2249 2249 * @hw: pointer to the hardware structure 2250 - * @recp_id: recipe id for which the rule needs to removed 2250 + * @recp_id: recipe ID for which the rule needs to removed 2251 2251 * @v_list: list of promisc entries 2252 2252 */ 2253 2253 static enum ice_status ··· 2572 2572 * ice_replay_vsi_fltr - Replay filters for requested VSI 2573 2573 * @hw: pointer to the hardware structure 2574 2574 * @vsi_handle: driver VSI handle 2575 - * @recp_id: Recipe id for which rules need to be replayed 2575 + * @recp_id: Recipe ID for which rules need to be replayed 2576 2576 * @list_head: list for which filters need to be replayed 2577 2577 * 2578 2578 * Replays the filter of recipe recp_id for a VSI represented via vsi_handle. ··· 2596 2596 f_entry.fltr_info = itr->fltr_info; 2597 2597 if (itr->vsi_count < 2 && recp_id != ICE_SW_LKUP_VLAN && 2598 2598 itr->fltr_info.vsi_handle == vsi_handle) { 2599 - /* update the src in case it is vsi num */ 2599 + /* update the src in case it is VSI num */ 2600 2600 if (f_entry.fltr_info.src_id == ICE_SRC_ID_VSI) 2601 2601 f_entry.fltr_info.src = hw_vsi_id; 2602 2602 status = ice_add_rule_internal(hw, recp_id, &f_entry); ··· 2611 2611 clear_bit(vsi_handle, itr->vsi_list_info->vsi_map); 2612 2612 f_entry.fltr_info.vsi_handle = vsi_handle; 2613 2613 f_entry.fltr_info.fltr_act = ICE_FWD_TO_VSI; 2614 - /* update the src in case it is vsi num */ 2614 + /* update the src in case it is VSI num */ 2615 2615 if (f_entry.fltr_info.src_id == ICE_SRC_ID_VSI) 2616 2616 f_entry.fltr_info.src = hw_vsi_id; 2617 2617 if (recp_id == ICE_SW_LKUP_VLAN) ··· 2651 2651 2652 2652 /** 2653 2653 * ice_rm_all_sw_replay_rule_info - deletes filter replay rules 2654 - * @hw: pointer to the hw struct 2654 + * @hw: pointer to the HW struct 2655 2655 * 2656 2656 * Deletes the filter replay rules. 2657 2657 */
+5 -5
drivers/net/ethernet/intel/ice/ice_switch.h
··· 44 44 ICE_SW_LKUP_LAST 45 45 }; 46 46 47 - /* type of filter src id */ 47 + /* type of filter src ID */ 48 48 enum ice_src_id { 49 49 ICE_SRC_ID_UNKNOWN = 0, 50 50 ICE_SRC_ID_VSI, ··· 95 95 96 96 /* Depending on filter action */ 97 97 union { 98 - /* queue id in case of ICE_FWD_TO_Q and starting 99 - * queue id in case of ICE_FWD_TO_QGRP. 98 + /* queue ID in case of ICE_FWD_TO_Q and starting 99 + * queue ID in case of ICE_FWD_TO_QGRP. 100 100 */ 101 101 u16 q_id:11; 102 102 u16 hw_vsi_id:10; ··· 143 143 DECLARE_BITMAP(r_bitmap, ICE_MAX_NUM_RECIPES); 144 144 }; 145 145 146 - /* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list id */ 146 + /* Bookkeeping structure to hold bitmap of VSIs corresponding to VSI list ID */ 147 147 struct ice_vsi_list_map_info { 148 148 struct list_head list_entry; 149 149 DECLARE_BITMAP(vsi_map, ICE_MAX_VSI); ··· 165 165 * used for VLAN membership. 166 166 */ 167 167 struct ice_fltr_mgmt_list_entry { 168 - /* back pointer to VSI list id to VSI list mapping */ 168 + /* back pointer to VSI list ID to VSI list mapping */ 169 169 struct ice_vsi_list_map_info *vsi_list_info; 170 170 u16 vsi_count; 171 171 #define ICE_INVAL_LG_ACT_INDEX 0xffff
+72 -81
drivers/net/ethernet/intel/ice/ice_txrx.c
··· 6 6 #include <linux/prefetch.h> 7 7 #include <linux/mm.h> 8 8 #include "ice.h" 9 + #include "ice_dcb_lib.h" 9 10 10 11 #define ICE_RX_HDR_SIZE 256 11 12 ··· 457 456 if (!rx_ring->netdev || !cleaned_count) 458 457 return false; 459 458 460 - /* get the RX descriptor and buffer based on next_to_use */ 459 + /* get the Rx descriptor and buffer based on next_to_use */ 461 460 rx_desc = ICE_RX_DESC(rx_ring, ntu); 462 461 bi = &rx_ring->rx_buf[ntu]; 463 462 ··· 960 959 * ice_receive_skb - Send a completed packet up the stack 961 960 * @rx_ring: Rx ring in play 962 961 * @skb: packet to send up 963 - * @vlan_tag: vlan tag for packet 962 + * @vlan_tag: VLAN tag for packet 964 963 * 965 964 * This function sends the completed packet (via. skb) up the stack using 966 - * gro receive functions (with/without vlan tag) 965 + * gro receive functions (with/without VLAN tag) 967 966 */ 968 967 static void 969 968 ice_receive_skb(struct ice_ring *rx_ring, struct sk_buff *skb, u16 vlan_tag) ··· 992 991 u16 cleaned_count = ICE_DESC_UNUSED(rx_ring); 993 992 bool failure = false; 994 993 995 - /* start the loop to process RX packets bounded by 'budget' */ 994 + /* start the loop to process Rx packets bounded by 'budget' */ 996 995 while (likely(total_rx_pkts < (unsigned int)budget)) { 997 996 union ice_32b_rx_flex_desc *rx_desc; 998 997 struct ice_rx_buf *rx_buf; ··· 1009 1008 cleaned_count = 0; 1010 1009 } 1011 1010 1012 - /* get the RX desc from RX ring based on 'next_to_clean' */ 1011 + /* get the Rx desc from Rx ring based on 'next_to_clean' */ 1013 1012 rx_desc = ICE_RX_DESC(rx_ring, rx_ring->next_to_clean); 1014 1013 1015 1014 /* status_error_len will always be zero for unused descriptors ··· 1097 1096 return failure ? budget : (int)total_rx_pkts; 1098 1097 } 1099 1098 1100 - static unsigned int ice_itr_divisor(struct ice_port_info *pi) 1099 + /** 1100 + * ice_adjust_itr_by_size_and_speed - Adjust ITR based on current traffic 1101 + * @port_info: port_info structure containing the current link speed 1102 + * @avg_pkt_size: average size of Tx or Rx packets based on clean routine 1103 + * @itr: itr value to update 1104 + * 1105 + * Calculate how big of an increment should be applied to the ITR value passed 1106 + * in based on wmem_default, SKB overhead, Ethernet overhead, and the current 1107 + * link speed. 1108 + * 1109 + * The following is a calculation derived from: 1110 + * wmem_default / (size + overhead) = desired_pkts_per_int 1111 + * rate / bits_per_byte / (size + Ethernet overhead) = pkt_rate 1112 + * (desired_pkt_rate / pkt_rate) * usecs_per_sec = ITR value 1113 + * 1114 + * Assuming wmem_default is 212992 and overhead is 640 bytes per 1115 + * packet, (256 skb, 64 headroom, 320 shared info), we can reduce the 1116 + * formula down to: 1117 + * 1118 + * wmem_default * bits_per_byte * usecs_per_sec pkt_size + 24 1119 + * ITR = -------------------------------------------- * -------------- 1120 + * rate pkt_size + 640 1121 + */ 1122 + static unsigned int 1123 + ice_adjust_itr_by_size_and_speed(struct ice_port_info *port_info, 1124 + unsigned int avg_pkt_size, 1125 + unsigned int itr) 1101 1126 { 1102 - switch (pi->phy.link_info.link_speed) { 1127 + switch (port_info->phy.link_info.link_speed) { 1128 + case ICE_AQ_LINK_SPEED_100GB: 1129 + itr += DIV_ROUND_UP(17 * (avg_pkt_size + 24), 1130 + avg_pkt_size + 640); 1131 + break; 1132 + case ICE_AQ_LINK_SPEED_50GB: 1133 + itr += DIV_ROUND_UP(34 * (avg_pkt_size + 24), 1134 + avg_pkt_size + 640); 1135 + break; 1103 1136 case ICE_AQ_LINK_SPEED_40GB: 1104 - return ICE_ITR_ADAPTIVE_MIN_INC * 1024; 1137 + itr += DIV_ROUND_UP(43 * (avg_pkt_size + 24), 1138 + avg_pkt_size + 640); 1139 + break; 1105 1140 case ICE_AQ_LINK_SPEED_25GB: 1141 + itr += DIV_ROUND_UP(68 * (avg_pkt_size + 24), 1142 + avg_pkt_size + 640); 1143 + break; 1106 1144 case ICE_AQ_LINK_SPEED_20GB: 1107 - return ICE_ITR_ADAPTIVE_MIN_INC * 512; 1108 - case ICE_AQ_LINK_SPEED_100MB: 1109 - return ICE_ITR_ADAPTIVE_MIN_INC * 32; 1145 + itr += DIV_ROUND_UP(85 * (avg_pkt_size + 24), 1146 + avg_pkt_size + 640); 1147 + break; 1148 + case ICE_AQ_LINK_SPEED_10GB: 1149 + /* fall through */ 1110 1150 default: 1111 - return ICE_ITR_ADAPTIVE_MIN_INC * 256; 1151 + itr += DIV_ROUND_UP(170 * (avg_pkt_size + 24), 1152 + avg_pkt_size + 640); 1153 + break; 1112 1154 } 1155 + 1156 + if ((itr & ICE_ITR_MASK) > ICE_ITR_ADAPTIVE_MAX_USECS) { 1157 + itr &= ICE_ITR_ADAPTIVE_LATENCY; 1158 + itr += ICE_ITR_ADAPTIVE_MAX_USECS; 1159 + } 1160 + 1161 + return itr; 1113 1162 } 1114 1163 1115 1164 /** ··· 1178 1127 static void 1179 1128 ice_update_itr(struct ice_q_vector *q_vector, struct ice_ring_container *rc) 1180 1129 { 1181 - unsigned int avg_wire_size, packets, bytes, itr; 1182 1130 unsigned long next_update = jiffies; 1131 + unsigned int packets, bytes, itr; 1183 1132 bool container_is_rx; 1184 1133 1185 1134 if (!rc->ring || !ITR_IS_DYNAMIC(rc->itr_setting)) ··· 1224 1173 if (packets && packets < 4 && bytes < 9000 && 1225 1174 (q_vector->tx.target_itr & ICE_ITR_ADAPTIVE_LATENCY)) { 1226 1175 itr = ICE_ITR_ADAPTIVE_LATENCY; 1227 - goto adjust_by_size; 1176 + goto adjust_by_size_and_speed; 1228 1177 } 1229 1178 } else if (packets < 4) { 1230 1179 /* If we have Tx and Rx ITR maxed and Tx ITR is running in ··· 1292 1241 */ 1293 1242 itr = ICE_ITR_ADAPTIVE_BULK; 1294 1243 1295 - adjust_by_size: 1296 - /* If packet counts are 256 or greater we can assume we have a gross 1297 - * overestimation of what the rate should be. Instead of trying to fine 1298 - * tune it just use the formula below to try and dial in an exact value 1299 - * gives the current packet size of the frame. 1300 - */ 1301 - avg_wire_size = bytes / packets; 1244 + adjust_by_size_and_speed: 1302 1245 1303 - /* The following is a crude approximation of: 1304 - * wmem_default / (size + overhead) = desired_pkts_per_int 1305 - * rate / bits_per_byte / (size + ethernet overhead) = pkt_rate 1306 - * (desired_pkt_rate / pkt_rate) * usecs_per_sec = ITR value 1307 - * 1308 - * Assuming wmem_default is 212992 and overhead is 640 bytes per 1309 - * packet, (256 skb, 64 headroom, 320 shared info), we can reduce the 1310 - * formula down to 1311 - * 1312 - * (170 * (size + 24)) / (size + 640) = ITR 1313 - * 1314 - * We first do some math on the packet size and then finally bitshift 1315 - * by 8 after rounding up. We also have to account for PCIe link speed 1316 - * difference as ITR scales based on this. 1317 - */ 1318 - if (avg_wire_size <= 60) { 1319 - /* Start at 250k ints/sec */ 1320 - avg_wire_size = 4096; 1321 - } else if (avg_wire_size <= 380) { 1322 - /* 250K ints/sec to 60K ints/sec */ 1323 - avg_wire_size *= 40; 1324 - avg_wire_size += 1696; 1325 - } else if (avg_wire_size <= 1084) { 1326 - /* 60K ints/sec to 36K ints/sec */ 1327 - avg_wire_size *= 15; 1328 - avg_wire_size += 11452; 1329 - } else if (avg_wire_size <= 1980) { 1330 - /* 36K ints/sec to 30K ints/sec */ 1331 - avg_wire_size *= 5; 1332 - avg_wire_size += 22420; 1333 - } else { 1334 - /* plateau at a limit of 30K ints/sec */ 1335 - avg_wire_size = 32256; 1336 - } 1337 - 1338 - /* If we are in low latency mode halve our delay which doubles the 1339 - * rate to somewhere between 100K to 16K ints/sec 1340 - */ 1341 - if (itr & ICE_ITR_ADAPTIVE_LATENCY) 1342 - avg_wire_size >>= 1; 1343 - 1344 - /* Resultant value is 256 times larger than it needs to be. This 1345 - * gives us room to adjust the value as needed to either increase 1346 - * or decrease the value based on link speeds of 10G, 2.5G, 1G, etc. 1347 - * 1348 - * Use addition as we have already recorded the new latency flag 1349 - * for the ITR value. 1350 - */ 1351 - itr += DIV_ROUND_UP(avg_wire_size, 1352 - ice_itr_divisor(q_vector->vsi->port_info)) * 1353 - ICE_ITR_ADAPTIVE_MIN_INC; 1354 - 1355 - if ((itr & ICE_ITR_MASK) > ICE_ITR_ADAPTIVE_MAX_USECS) { 1356 - itr &= ICE_ITR_ADAPTIVE_LATENCY; 1357 - itr += ICE_ITR_ADAPTIVE_MAX_USECS; 1358 - } 1246 + /* based on checks above packets cannot be 0 so division is safe */ 1247 + itr = ice_adjust_itr_by_size_and_speed(q_vector->vsi->port_info, 1248 + bytes / packets, itr); 1359 1249 1360 1250 clear_counts: 1361 1251 /* write back value */ ··· 1764 1772 } 1765 1773 1766 1774 /** 1767 - * ice_tx_prepare_vlan_flags - prepare generic TX VLAN tagging flags for HW 1775 + * ice_tx_prepare_vlan_flags - prepare generic Tx VLAN tagging flags for HW 1768 1776 * @tx_ring: ring to send buffer on 1769 1777 * @first: pointer to struct ice_tx_buf 1770 1778 * ··· 1790 1798 * to the encapsulated ethertype. 1791 1799 */ 1792 1800 skb->protocol = vlan_get_protocol(skb); 1793 - goto out; 1801 + return 0; 1794 1802 } 1795 1803 1796 1804 /* if we have a HW VLAN tag being added, default to the HW one */ ··· 1812 1820 first->tx_flags |= ICE_TX_FLAGS_SW_VLAN; 1813 1821 } 1814 1822 1815 - out: 1816 - return 0; 1823 + return ice_tx_prepare_vlan_flags_dcb(tx_ring, first); 1817 1824 } 1818 1825 1819 1826 /**
+5
drivers/net/ethernet/intel/ice/ice_txrx.h
··· 45 45 #define ICE_TX_FLAGS_HW_VLAN BIT(1) 46 46 #define ICE_TX_FLAGS_SW_VLAN BIT(2) 47 47 #define ICE_TX_FLAGS_VLAN_M 0xffff0000 48 + #define ICE_TX_FLAGS_VLAN_PR_M 0xe0000000 49 + #define ICE_TX_FLAGS_VLAN_PR_S 29 48 50 #define ICE_TX_FLAGS_VLAN_S 16 49 51 50 52 #define ICE_RX_DMA_ATTR \ ··· 162 160 }; 163 161 u16 q_index; /* Queue number of ring */ 164 162 u32 txq_teid; /* Added Tx queue TEID */ 163 + #ifdef CONFIG_DCB 164 + u8 dcb_tc; /* Traffic class of ring */ 165 + #endif /* CONFIG_DCB */ 165 166 166 167 u16 count; /* Number of descriptors */ 167 168 u16 reg_idx; /* HW register index of the ring */
+80 -11
drivers/net/ethernet/intel/ice/ice_type.h
··· 107 107 }; 108 108 109 109 /* Different reset sources for which a disable queue AQ call has to be made in 110 - * order to clean the TX scheduler as a part of the reset 110 + * order to clean the Tx scheduler as a part of the reset 111 111 */ 112 112 enum ice_disq_rst_src { 113 113 ICE_NO_RESET = 0, ··· 129 129 struct ice_hw_common_caps { 130 130 u32 valid_functions; 131 131 132 - /* TX/RX queues */ 133 - u16 num_rxq; /* Number/Total RX queues */ 134 - u16 rxq_first_id; /* First queue ID for RX queues */ 135 - u16 num_txq; /* Number/Total TX queues */ 136 - u16 txq_first_id; /* First queue ID for TX queues */ 132 + /* Tx/Rx queues */ 133 + u16 num_rxq; /* Number/Total Rx queues */ 134 + u16 rxq_first_id; /* First queue ID for Rx queues */ 135 + u16 num_txq; /* Number/Total Tx queues */ 136 + u16 txq_first_id; /* First queue ID for Tx queues */ 137 137 138 138 /* MSI-X vectors */ 139 139 u16 num_msix_vectors; ··· 148 148 /* RSS related capabilities */ 149 149 u16 rss_table_size; /* 512 for PFs and 64 for VFs */ 150 150 u8 rss_table_entry_width; /* RSS Entry width in bits */ 151 + 152 + u8 dcb; 151 153 }; 152 154 153 155 /* Function specific capabilities */ ··· 215 213 #define ice_for_each_traffic_class(_i) \ 216 214 for ((_i) = 0; (_i) < ICE_MAX_TRAFFIC_CLASS; (_i)++) 217 215 216 + #define ICE_INVAL_TEID 0xFFFFFFFF 217 + 218 218 struct ice_sched_node { 219 219 struct ice_sched_node *parent; 220 220 struct ice_sched_node *sibling; /* next sibling in the same layer */ 221 221 struct ice_sched_node **children; 222 222 struct ice_aqc_txsched_elem_data info; 223 - u32 agg_id; /* aggregator group id */ 223 + u32 agg_id; /* aggregator group ID */ 224 224 u16 vsi_handle; 225 225 u8 in_use; /* suspended or in use */ 226 226 u8 tx_sched_layer; /* Logical Layer (1-9) */ ··· 249 245 #define ICE_SCHED_DFLT_RL_PROF_ID 0 250 246 #define ICE_SCHED_DFLT_BW_WT 1 251 247 252 - /* vsi type list entry to locate corresponding vsi/ag nodes */ 248 + /* VSI type list entry to locate corresponding VSI/ag nodes */ 253 249 struct ice_sched_vsi_info { 254 250 struct ice_sched_node *vsi_node[ICE_MAX_TRAFFIC_CLASS]; 255 251 struct ice_sched_node *ag_node[ICE_MAX_TRAFFIC_CLASS]; ··· 264 260 u8 rdma_ena; 265 261 }; 266 262 263 + /* CEE or IEEE 802.1Qaz ETS Configuration data */ 264 + struct ice_dcb_ets_cfg { 265 + u8 willing; 266 + u8 cbs; 267 + u8 maxtcs; 268 + u8 prio_table[ICE_MAX_TRAFFIC_CLASS]; 269 + u8 tcbwtable[ICE_MAX_TRAFFIC_CLASS]; 270 + u8 tsatable[ICE_MAX_TRAFFIC_CLASS]; 271 + }; 272 + 273 + /* CEE or IEEE 802.1Qaz PFC Configuration data */ 274 + struct ice_dcb_pfc_cfg { 275 + u8 willing; 276 + u8 mbc; 277 + u8 pfccap; 278 + u8 pfcena; 279 + }; 280 + 281 + /* CEE or IEEE 802.1Qaz Application Priority data */ 282 + struct ice_dcb_app_priority_table { 283 + u16 prot_id; 284 + u8 priority; 285 + u8 selector; 286 + }; 287 + 288 + #define ICE_MAX_USER_PRIORITY 8 289 + #define ICE_DCBX_MAX_APPS 32 290 + #define ICE_LLDPDU_SIZE 1500 291 + #define ICE_TLV_STATUS_OPER 0x1 292 + #define ICE_TLV_STATUS_SYNC 0x2 293 + #define ICE_TLV_STATUS_ERR 0x4 294 + #define ICE_APP_PROT_ID_FCOE 0x8906 295 + #define ICE_APP_PROT_ID_ISCSI 0x0cbc 296 + #define ICE_APP_PROT_ID_FIP 0x8914 297 + #define ICE_APP_SEL_ETHTYPE 0x1 298 + #define ICE_APP_SEL_TCPIP 0x2 299 + #define ICE_CEE_APP_SEL_ETHTYPE 0x0 300 + #define ICE_CEE_APP_SEL_TCPIP 0x1 301 + 302 + struct ice_dcbx_cfg { 303 + u32 numapps; 304 + u32 tlv_status; /* CEE mode TLV status */ 305 + struct ice_dcb_ets_cfg etscfg; 306 + struct ice_dcb_ets_cfg etsrec; 307 + struct ice_dcb_pfc_cfg pfc; 308 + struct ice_dcb_app_priority_table app[ICE_DCBX_MAX_APPS]; 309 + u8 dcbx_mode; 310 + #define ICE_DCBX_MODE_CEE 0x1 311 + #define ICE_DCBX_MODE_IEEE 0x2 312 + u8 app_mode; 313 + #define ICE_DCBX_APPS_NON_WILLING 0x1 314 + }; 315 + 267 316 struct ice_port_info { 268 317 struct ice_sched_node *root; /* Root Node per Port */ 269 - struct ice_hw *hw; /* back pointer to hw instance */ 318 + struct ice_hw *hw; /* back pointer to HW instance */ 270 319 u32 last_node_teid; /* scheduler last node info */ 271 320 u16 sw_id; /* Initial switch ID belongs to port */ 272 321 u16 pf_vf_num; ··· 334 277 struct ice_mac_info mac; 335 278 struct ice_phy_info phy; 336 279 struct mutex sched_lock; /* protect access to TXSched tree */ 280 + struct ice_dcbx_cfg local_dcbx_cfg; /* Oper/Local Cfg */ 281 + /* DCBX info */ 282 + struct ice_dcbx_cfg remote_dcbx_cfg; /* Peer Cfg */ 283 + struct ice_dcbx_cfg desired_dcbx_cfg; /* CEE Desired Cfg */ 284 + /* LLDP/DCBX Status */ 285 + u8 dcbx_status; 286 + u8 is_sw_lldp; 337 287 u8 lport; 338 288 #define ICE_LPORT_MASK 0xff 339 289 u8 is_vf; ··· 387 323 388 324 u8 pf_id; /* device profile info */ 389 325 390 - /* TX Scheduler values */ 326 + /* Tx Scheduler values */ 391 327 u16 num_tx_sched_layers; 392 328 u16 num_tx_sched_phys_layers; 393 329 u8 flattened_layers; ··· 398 334 399 335 struct ice_vsi_ctx *vsi_ctx[ICE_MAX_VSI]; 400 336 u8 evb_veb; /* true for VEB, false for VEPA */ 401 - u8 reset_ongoing; /* true if hw is in reset, false otherwise */ 337 + u8 reset_ongoing; /* true if HW is in reset, false otherwise */ 402 338 struct ice_bus_info bus; 403 339 struct ice_nvm_info nvm; 404 340 struct ice_hw_dev_caps dev_caps; /* device capabilities */ ··· 477 413 u64 link_xoff_rx; /* lxoffrxc */ 478 414 u64 link_xon_tx; /* lxontxc */ 479 415 u64 link_xoff_tx; /* lxofftxc */ 416 + u64 priority_xon_rx[8]; /* pxonrxc[8] */ 417 + u64 priority_xoff_rx[8]; /* pxoffrxc[8] */ 418 + u64 priority_xon_tx[8]; /* pxontxc[8] */ 419 + u64 priority_xoff_tx[8]; /* pxofftxc[8] */ 420 + u64 priority_xon_2_xoff[8]; /* pxon2offc[8] */ 480 421 u64 rx_size_64; /* prc64 */ 481 422 u64 rx_size_127; /* prc127 */ 482 423 u64 rx_size_255; /* prc255 */
+28 -28
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.c
··· 375 375 } 376 376 377 377 /** 378 - * ice_vsi_set_pvid_fill_ctxt - Set VSI ctxt for add pvid 379 - * @ctxt: the vsi ctxt to fill 380 - * @vid: the VLAN id to set as a PVID 378 + * ice_vsi_set_pvid_fill_ctxt - Set VSI ctxt for add PVID 379 + * @ctxt: the VSI ctxt to fill 380 + * @vid: the VLAN ID to set as a PVID 381 381 */ 382 382 static void ice_vsi_set_pvid_fill_ctxt(struct ice_vsi_ctx *ctxt, u16 vid) 383 383 { ··· 391 391 } 392 392 393 393 /** 394 - * ice_vsi_kill_pvid_fill_ctxt - Set VSI ctx for remove pvid 394 + * ice_vsi_kill_pvid_fill_ctxt - Set VSI ctx for remove PVID 395 395 * @ctxt: the VSI ctxt to fill 396 396 */ 397 397 static void ice_vsi_kill_pvid_fill_ctxt(struct ice_vsi_ctx *ctxt) ··· 406 406 /** 407 407 * ice_vsi_manage_pvid - Enable or disable port VLAN for VSI 408 408 * @vsi: the VSI to update 409 - * @vid: the VLAN id to set as a PVID 410 - * @enable: true for enable pvid false for disable 409 + * @vid: the VLAN ID to set as a PVID 410 + * @enable: true for enable PVID false for disable 411 411 */ 412 412 static int ice_vsi_manage_pvid(struct ice_vsi *vsi, u16 vid, bool enable) 413 413 { ··· 445 445 * ice_vf_vsi_setup - Set up a VF VSI 446 446 * @pf: board private structure 447 447 * @pi: pointer to the port_info instance 448 - * @vf_id: defines VF id to which this VSI connects. 448 + * @vf_id: defines VF ID to which this VSI connects. 449 449 * 450 450 * Returns pointer to the successfully allocated VSI struct on success, 451 451 * otherwise returns NULL on failure. ··· 513 513 514 514 /* Clear this bit after VF initialization since we shouldn't reclaim 515 515 * and reassign interrupts for synchronous or asynchronous VFR events. 516 - * We dont want to reconfigure interrupts since AVF driver doesn't 516 + * We don't want to reconfigure interrupts since AVF driver doesn't 517 517 * expect vector assignment to be changed unless there is a request for 518 518 * more vectors. 519 519 */ ··· 1508 1508 /** 1509 1509 * ice_find_vsi_from_id 1510 1510 * @pf: the pf structure to search for the VSI 1511 - * @id: id of the VSI it is searching for 1511 + * @id: ID of the VSI it is searching for 1512 1512 * 1513 - * searches for the VSI with the given id 1513 + * searches for the VSI with the given ID 1514 1514 */ 1515 1515 static struct ice_vsi *ice_find_vsi_from_id(struct ice_pf *pf, u16 id) 1516 1516 { ··· 1526 1526 /** 1527 1527 * ice_vc_isvalid_vsi_id 1528 1528 * @vf: pointer to the VF info 1529 - * @vsi_id: VF relative VSI id 1529 + * @vsi_id: VF relative VSI ID 1530 1530 * 1531 - * check for the valid VSI id 1531 + * check for the valid VSI ID 1532 1532 */ 1533 1533 static bool ice_vc_isvalid_vsi_id(struct ice_vf *vf, u16 vsi_id) 1534 1534 { ··· 1543 1543 /** 1544 1544 * ice_vc_isvalid_q_id 1545 1545 * @vf: pointer to the VF info 1546 - * @vsi_id: VSI id 1547 - * @qid: VSI relative queue id 1546 + * @vsi_id: VSI ID 1547 + * @qid: VSI relative queue ID 1548 1548 * 1549 - * check for the valid queue id 1549 + * check for the valid queue ID 1550 1550 */ 1551 1551 static bool ice_vc_isvalid_q_id(struct ice_vf *vf, u16 vsi_id, u8 qid) 1552 1552 { ··· 2005 2005 * ice_vc_handle_mac_addr_msg 2006 2006 * @vf: pointer to the VF info 2007 2007 * @msg: pointer to the msg buffer 2008 - * @set: true if mac filters are being set, false otherwise 2008 + * @set: true if MAC filters are being set, false otherwise 2009 2009 * 2010 2010 * add guest MAC address filter 2011 2011 */ ··· 2065 2065 maddr, vf->vf_id); 2066 2066 continue; 2067 2067 } else { 2068 - /* VF can't remove dflt_lan_addr/bcast mac */ 2068 + /* VF can't remove dflt_lan_addr/bcast MAC */ 2069 2069 dev_err(&pf->pdev->dev, 2070 2070 "VF can't remove default MAC address or MAC %pM programmed by PF for VF %d\n", 2071 2071 maddr, vf->vf_id); ··· 2091 2091 goto handle_mac_exit; 2092 2092 } 2093 2093 2094 - /* get here if maddr is multicast or if VF can change mac */ 2094 + /* get here if maddr is multicast or if VF can change MAC */ 2095 2095 if (ice_add_mac_to_list(vsi, &mac_list, al->list[i].addr)) { 2096 2096 v_ret = VIRTCHNL_STATUS_ERR_NO_MEMORY; 2097 2097 goto handle_mac_exit; ··· 2154 2154 * VFs get a default number of queues but can use this message to request a 2155 2155 * different number. If the request is successful, PF will reset the VF and 2156 2156 * return 0. If unsuccessful, PF will send message informing VF of number of 2157 - * available queue pairs via virtchnl message response to vf. 2157 + * available queue pairs via virtchnl message response to VF. 2158 2158 */ 2159 2159 static int ice_vc_request_qs_msg(struct ice_vf *vf, u8 *msg) 2160 2160 { ··· 2210 2210 * ice_set_vf_port_vlan 2211 2211 * @netdev: network interface device structure 2212 2212 * @vf_id: VF identifier 2213 - * @vlan_id: VLAN id being set 2213 + * @vlan_id: VLAN ID being set 2214 2214 * @qos: priority setting 2215 2215 * @vlan_proto: VLAN protocol 2216 2216 * 2217 - * program VF Port VLAN id and/or qos 2217 + * program VF Port VLAN ID and/or QoS 2218 2218 */ 2219 2219 int 2220 2220 ice_set_vf_port_vlan(struct net_device *netdev, int vf_id, u16 vlan_id, u8 qos, ··· 2257 2257 return ret; 2258 2258 } 2259 2259 2260 - /* If pvid, then remove all filters on the old VLAN */ 2260 + /* If PVID, then remove all filters on the old VLAN */ 2261 2261 if (vsi->info.pvid) 2262 2262 ice_vsi_kill_vlan(vsi, (le16_to_cpu(vsi->info.pvid) & 2263 2263 VLAN_VID_MASK)); ··· 2296 2296 * @msg: pointer to the msg buffer 2297 2297 * @add_v: Add VLAN if true, otherwise delete VLAN 2298 2298 * 2299 - * Process virtchnl op to add or remove programmed guest VLAN id 2299 + * Process virtchnl op to add or remove programmed guest VLAN ID 2300 2300 */ 2301 2301 static int ice_vc_process_vlan_msg(struct ice_vf *vf, u8 *msg, bool add_v) 2302 2302 { ··· 2443 2443 * @vf: pointer to the VF info 2444 2444 * @msg: pointer to the msg buffer 2445 2445 * 2446 - * Add and program guest VLAN id 2446 + * Add and program guest VLAN ID 2447 2447 */ 2448 2448 static int ice_vc_add_vlan_msg(struct ice_vf *vf, u8 *msg) 2449 2449 { ··· 2455 2455 * @vf: pointer to the VF info 2456 2456 * @msg: pointer to the msg buffer 2457 2457 * 2458 - * remove programmed guest VLAN id 2458 + * remove programmed guest VLAN ID 2459 2459 */ 2460 2460 static int ice_vc_remove_vlan_msg(struct ice_vf *vf, u8 *msg) 2461 2461 { ··· 2771 2771 * ice_set_vf_mac 2772 2772 * @netdev: network interface device structure 2773 2773 * @vf_id: VF identifier 2774 - * @mac: mac address 2774 + * @mac: MAC address 2775 2775 * 2776 - * program VF mac address 2776 + * program VF MAC address 2777 2777 */ 2778 2778 int ice_set_vf_mac(struct net_device *netdev, int vf_id, u8 *mac) 2779 2779 { ··· 2800 2800 return -EINVAL; 2801 2801 } 2802 2802 2803 - /* copy mac into dflt_lan_addr and trigger a VF reset. The reset 2803 + /* copy MAC into dflt_lan_addr and trigger a VF reset. The reset 2804 2804 * flow will use the updated dflt_lan_addr and add a MAC filter 2805 2805 * using ice_add_mac. Also set pf_set_mac to indicate that the PF has 2806 2806 * set the MAC address for this VF.
+4 -4
drivers/net/ethernet/intel/ice/ice_virtchnl_pf.h
··· 48 48 struct ice_vf { 49 49 struct ice_pf *pf; 50 50 51 - s16 vf_id; /* VF id in the PF space */ 51 + s16 vf_id; /* VF ID in the PF space */ 52 52 u32 driver_caps; /* reported by VF driver */ 53 53 int first_vector_idx; /* first vector index of this VF */ 54 - struct ice_sw *vf_sw_id; /* switch id the VF VSIs connect to */ 54 + struct ice_sw *vf_sw_id; /* switch ID the VF VSIs connect to */ 55 55 struct virtchnl_version_info vf_ver; 56 56 struct virtchnl_ether_addr dflt_lan_addr; 57 57 u16 port_vlan_id; ··· 59 59 u8 trusted; 60 60 u16 lan_vsi_idx; /* index into PF struct */ 61 61 u16 lan_vsi_num; /* ID as used by firmware */ 62 - u64 num_mdd_events; /* number of mdd events detected */ 62 + u64 num_mdd_events; /* number of MDD events detected */ 63 63 u64 num_inval_msgs; /* number of continuous invalid msgs */ 64 64 u64 num_valid_msgs; /* number of valid msgs detected */ 65 - unsigned long vf_caps; /* vf's adv. capabilities */ 65 + unsigned long vf_caps; /* VF's adv. capabilities */ 66 66 DECLARE_BITMAP(vf_states, ICE_VF_STATES_NBITS); /* VF runtime states */ 67 67 unsigned int tx_rate; /* Tx bandwidth limit in Mbps */ 68 68 u8 link_forced;