Skip to content

Commit cdedef5

Browse files
refactormanJeff Kirsher
authored andcommitted
ice: Configure VSIs for Tx/Rx
This patch configures the VSIs to be able to send and receive packets by doing the following: 1) Initialize flexible parser to extract and include certain fields in the Rx descriptor. 2) Add Tx queues by programming the Tx queue context (implemented in ice_vsi_cfg_txqs). Note that adding the queues also enables (starts) the queues. 3) Add Rx queues by programming Rx queue context (implemented in ice_vsi_cfg_rxqs). Note that this only adds queues but doesn't start them. The rings will be started by calling ice_vsi_start_rx_rings on interface up. 4) Configure interrupts for VSI queues. 5) Implement ice_open and ice_stop. Signed-off-by: Anirudh Venkataramanan <[email protected]> Tested-by: Tony Brelinski <[email protected]> Signed-off-by: Jeff Kirsher <[email protected]>
1 parent 9daf820 commit cdedef5

File tree

14 files changed

+2752
-29
lines changed

14 files changed

+2752
-29
lines changed

drivers/net/ethernet/intel/ice/Makefile

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -12,4 +12,5 @@ ice-y := ice_main.o \
1212
ice_common.o \
1313
ice_nvm.o \
1414
ice_switch.o \
15-
ice_sched.o
15+
ice_sched.o \
16+
ice_txrx.o

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

Lines changed: 33 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -11,8 +11,10 @@
1111
#include <linux/netdevice.h>
1212
#include <linux/compiler.h>
1313
#include <linux/etherdevice.h>
14+
#include <linux/skbuff.h>
1415
#include <linux/cpumask.h>
1516
#include <linux/if_vlan.h>
17+
#include <linux/dma-mapping.h>
1618
#include <linux/pci.h>
1719
#include <linux/workqueue.h>
1820
#include <linux/aer.h>
@@ -43,6 +45,8 @@
4345
#define ICE_VSI_MAP_SCATTER 1
4446
#define ICE_MAX_SCATTER_TXQS 16
4547
#define ICE_MAX_SCATTER_RXQS 16
48+
#define ICE_Q_WAIT_RETRY_LIMIT 10
49+
#define ICE_Q_WAIT_MAX_RETRY (5 * ICE_Q_WAIT_RETRY_LIMIT)
4650
#define ICE_RES_VALID_BIT 0x8000
4751
#define ICE_RES_MISC_VEC_ID (ICE_RES_VALID_BIT - 1)
4852
#define ICE_INVAL_Q_INDEX 0xffff
@@ -56,6 +60,14 @@
5660
(((val) << ICE_AQ_VSI_UP_TABLE_UP##i##_S) & \
5761
ICE_AQ_VSI_UP_TABLE_UP##i##_M)
5862

63+
#define ICE_RX_DESC(R, i) (&(((union ice_32b_rx_flex_desc *)((R)->desc))[i]))
64+
65+
#define ice_for_each_txq(vsi, i) \
66+
for ((i) = 0; (i) < (vsi)->num_txq; (i)++)
67+
68+
#define ice_for_each_rxq(vsi, i) \
69+
for ((i) = 0; (i) < (vsi)->num_rxq; (i)++)
70+
5971
struct ice_tc_info {
6072
u16 qoffset;
6173
u16 qcount;
@@ -96,6 +108,9 @@ struct ice_vsi {
96108
struct ice_ring **rx_rings; /* rx ring array */
97109
struct ice_ring **tx_rings; /* tx ring array */
98110
struct ice_q_vector **q_vectors; /* q_vector array */
111+
112+
irqreturn_t (*irq_handler)(int irq, void *data);
113+
99114
DECLARE_BITMAP(state, __ICE_STATE_NBITS);
100115
int num_q_vectors;
101116
int base_vector;
@@ -106,8 +121,14 @@ struct ice_vsi {
106121
/* Interrupt thresholds */
107122
u16 work_lmt;
108123

124+
u16 max_frame;
125+
u16 rx_buf_len;
126+
109127
struct ice_aqc_vsi_props info; /* VSI properties */
110128

129+
bool irqs_ready;
130+
bool current_isup; /* Sync 'link up' logging */
131+
111132
/* queue information */
112133
u8 tx_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
113134
u8 rx_mapping_mode; /* ICE_MAP_MODE_[CONTIG|SCATTER] */
@@ -128,9 +149,11 @@ struct ice_q_vector {
128149
struct napi_struct napi;
129150
struct ice_ring_container rx;
130151
struct ice_ring_container tx;
152+
struct irq_affinity_notify affinity_notify;
131153
u16 v_idx; /* index in the vsi->q_vector array. */
132154
u8 num_ring_tx; /* total number of tx rings in vector */
133155
u8 num_ring_rx; /* total number of rx rings in vector */
156+
char name[ICE_INT_NAME_STR_LEN];
134157
} ____cacheline_internodealigned_in_smp;
135158

136159
enum ice_pf_flags {
@@ -178,10 +201,14 @@ struct ice_netdev_priv {
178201
/**
179202
* ice_irq_dynamic_ena - Enable default interrupt generation settings
180203
* @hw: pointer to hw struct
204+
* @vsi: pointer to vsi struct, can be NULL
205+
* @q_vector: pointer to q_vector, can be NULL
181206
*/
182-
static inline void ice_irq_dynamic_ena(struct ice_hw *hw)
207+
static inline void ice_irq_dynamic_ena(struct ice_hw *hw, struct ice_vsi *vsi,
208+
struct ice_q_vector *q_vector)
183209
{
184-
u32 vector = ((struct ice_pf *)hw->back)->oicr_idx;
210+
u32 vector = (vsi && q_vector) ? vsi->base_vector + q_vector->v_idx :
211+
((struct ice_pf *)hw->back)->oicr_idx;
185212
int itr = ICE_ITR_NONE;
186213
u32 val;
187214

@@ -190,7 +217,10 @@ static inline void ice_irq_dynamic_ena(struct ice_hw *hw)
190217
*/
191218
val = GLINT_DYN_CTL_INTENA_M | GLINT_DYN_CTL_CLEARPBA_M |
192219
(itr << GLINT_DYN_CTL_ITR_INDX_S);
193-
220+
if (vsi)
221+
if (test_bit(__ICE_DOWN, vsi->state))
222+
return;
194223
wr32(hw, GLINT_DYN_CTL(vector), val);
195224
}
225+
196226
#endif /* _ICE_H_ */

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

Lines changed: 86 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -968,6 +968,87 @@ struct ice_aqc_nvm {
968968
__le32 addr_low;
969969
};
970970

971+
/* Add TX LAN Queues (indirect 0x0C30) */
972+
struct ice_aqc_add_txqs {
973+
u8 num_qgrps;
974+
u8 reserved[3];
975+
__le32 reserved1;
976+
__le32 addr_high;
977+
__le32 addr_low;
978+
};
979+
980+
/* This is the descriptor of each queue entry for the Add TX LAN Queues
981+
* command (0x0C30). Only used within struct ice_aqc_add_tx_qgrp.
982+
*/
983+
struct ice_aqc_add_txqs_perq {
984+
__le16 txq_id;
985+
u8 rsvd[2];
986+
__le32 q_teid;
987+
u8 txq_ctx[22];
988+
u8 rsvd2[2];
989+
struct ice_aqc_txsched_elem info;
990+
};
991+
992+
/* The format of the command buffer for Add TX LAN Queues (0x0C30)
993+
* is an array of the following structs. Please note that the length of
994+
* each struct ice_aqc_add_tx_qgrp is variable due
995+
* to the variable number of queues in each group!
996+
*/
997+
struct ice_aqc_add_tx_qgrp {
998+
__le32 parent_teid;
999+
u8 num_txqs;
1000+
u8 rsvd[3];
1001+
struct ice_aqc_add_txqs_perq txqs[1];
1002+
};
1003+
1004+
/* Disable TX LAN Queues (indirect 0x0C31) */
1005+
struct ice_aqc_dis_txqs {
1006+
u8 cmd_type;
1007+
#define ICE_AQC_Q_DIS_CMD_S 0
1008+
#define ICE_AQC_Q_DIS_CMD_M (0x3 << ICE_AQC_Q_DIS_CMD_S)
1009+
#define ICE_AQC_Q_DIS_CMD_NO_FUNC_RESET (0 << ICE_AQC_Q_DIS_CMD_S)
1010+
#define ICE_AQC_Q_DIS_CMD_VM_RESET BIT(ICE_AQC_Q_DIS_CMD_S)
1011+
#define ICE_AQC_Q_DIS_CMD_VF_RESET (2 << ICE_AQC_Q_DIS_CMD_S)
1012+
#define ICE_AQC_Q_DIS_CMD_PF_RESET (3 << ICE_AQC_Q_DIS_CMD_S)
1013+
#define ICE_AQC_Q_DIS_CMD_SUBSEQ_CALL BIT(2)
1014+
#define ICE_AQC_Q_DIS_CMD_FLUSH_PIPE BIT(3)
1015+
u8 num_entries;
1016+
__le16 vmvf_and_timeout;
1017+
#define ICE_AQC_Q_DIS_VMVF_NUM_S 0
1018+
#define ICE_AQC_Q_DIS_VMVF_NUM_M (0x3FF << ICE_AQC_Q_DIS_VMVF_NUM_S)
1019+
#define ICE_AQC_Q_DIS_TIMEOUT_S 10
1020+
#define ICE_AQC_Q_DIS_TIMEOUT_M (0x3F << ICE_AQC_Q_DIS_TIMEOUT_S)
1021+
__le32 blocked_cgds;
1022+
__le32 addr_high;
1023+
__le32 addr_low;
1024+
};
1025+
1026+
/* The buffer for Disable TX LAN Queues (indirect 0x0C31)
1027+
* contains the following structures, arrayed one after the
1028+
* other.
1029+
* Note: Since the q_id is 16 bits wide, if the
1030+
* number of queues is even, then 2 bytes of alignment MUST be
1031+
* added before the start of the next group, to allow correct
1032+
* alignment of the parent_teid field.
1033+
*/
1034+
struct ice_aqc_dis_txq_item {
1035+
__le32 parent_teid;
1036+
u8 num_qs;
1037+
u8 rsvd;
1038+
/* The length of the q_id array varies according to num_qs */
1039+
__le16 q_id[1];
1040+
/* This only applies from F8 onward */
1041+
#define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S 15
1042+
#define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_LAN_Q \
1043+
(0 << ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S)
1044+
#define ICE_AQC_Q_DIS_BUF_ELEM_TYPE_RDMA_QSET \
1045+
(1 << ICE_AQC_Q_DIS_BUF_ELEM_TYPE_S)
1046+
};
1047+
1048+
struct ice_aqc_dis_txq {
1049+
struct ice_aqc_dis_txq_item qgrps[1];
1050+
};
1051+
9711052
/**
9721053
* struct ice_aq_desc - Admin Queue (AQ) descriptor
9731054
* @flags: ICE_AQ_FLAG_* flags
@@ -1008,6 +1089,8 @@ struct ice_aq_desc {
10081089
struct ice_aqc_query_txsched_res query_sched_res;
10091090
struct ice_aqc_add_move_delete_elem add_move_delete_elem;
10101091
struct ice_aqc_nvm nvm;
1092+
struct ice_aqc_add_txqs add_txqs;
1093+
struct ice_aqc_dis_txqs dis_txqs;
10111094
struct ice_aqc_add_get_update_free_vsi vsi_cmd;
10121095
struct ice_aqc_alloc_free_res_cmd sw_res_ctrl;
10131096
struct ice_aqc_get_link_status get_link_status;
@@ -1088,6 +1171,9 @@ enum ice_adminq_opc {
10881171
/* NVM commands */
10891172
ice_aqc_opc_nvm_read = 0x0701,
10901173

1174+
/* TX queue handling commands/events */
1175+
ice_aqc_opc_add_txqs = 0x0C30,
1176+
ice_aqc_opc_dis_txqs = 0x0C31,
10911177
};
10921178

10931179
#endif /* _ICE_ADMINQ_CMD_H_ */

0 commit comments

Comments
 (0)