Skip to content

Commit d4d5587

Browse files
plinga1anguy11
authored andcommitted
idpf: initialize interrupts and enable vport
To further continue 'vport open', initialize all the resources required for the interrupts. To start with, initialize the queue vector indices with the ones received from the device Control Plane. Now that all the TX and RX queues are initialized, map the RX descriptor and buffer queues as well as TX completion queues to the allocated vectors. Initialize and enable the napi handler for the napi polling. Finally, request the IRQs for the interrupt vectors from the stack and setup the interrupt handler. Once the interrupt init is done, send 'map queue vector', 'enable queues' and 'enable vport' virtchnl messages to the CP to complete the 'vport open' flow. Co-developed-by: Alan Brady <[email protected]> Signed-off-by: Alan Brady <[email protected]> Co-developed-by: Joshua Hay <[email protected]> Signed-off-by: Joshua Hay <[email protected]> Co-developed-by: Madhu Chittim <[email protected]> Signed-off-by: Madhu Chittim <[email protected]> Co-developed-by: Phani Burra <[email protected]> Signed-off-by: Phani Burra <[email protected]> Reviewed-by: Sridhar Samudrala <[email protected]> Reviewed-by: Willem de Bruijn <[email protected]> Signed-off-by: Pavan Kumar Linga <[email protected]> Signed-off-by: Tony Nguyen <[email protected]>
1 parent 95af467 commit d4d5587

File tree

10 files changed

+1389
-3
lines changed

10 files changed

+1389
-3
lines changed

drivers/net/ethernet/intel/idpf/idpf.h

Lines changed: 45 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -176,12 +176,14 @@ struct idpf_vport_max_q {
176176
/**
177177
* struct idpf_reg_ops - Device specific register operation function pointers
178178
* @ctlq_reg_init: Mailbox control queue register initialization
179+
* @intr_reg_init: Traffic interrupt register initialization
179180
* @mb_intr_reg_init: Mailbox interrupt register initialization
180181
* @reset_reg_init: Reset register initialization
181182
* @trigger_reset: Trigger a reset to occur
182183
*/
183184
struct idpf_reg_ops {
184185
void (*ctlq_reg_init)(struct idpf_ctlq_create_info *cq);
186+
int (*intr_reg_init)(struct idpf_vport *vport);
185187
void (*mb_intr_reg_init)(struct idpf_adapter *adapter);
186188
void (*reset_reg_init)(struct idpf_adapter *adapter);
187189
void (*trigger_reset)(struct idpf_adapter *adapter,
@@ -204,12 +206,24 @@ struct idpf_dev_ops {
204206
#define IDPF_FOREACH_VPORT_VC_STATE(STATE) \
205207
STATE(IDPF_VC_CREATE_VPORT) \
206208
STATE(IDPF_VC_CREATE_VPORT_ERR) \
209+
STATE(IDPF_VC_ENA_VPORT) \
210+
STATE(IDPF_VC_ENA_VPORT_ERR) \
211+
STATE(IDPF_VC_DIS_VPORT) \
212+
STATE(IDPF_VC_DIS_VPORT_ERR) \
207213
STATE(IDPF_VC_DESTROY_VPORT) \
208214
STATE(IDPF_VC_DESTROY_VPORT_ERR) \
209215
STATE(IDPF_VC_CONFIG_TXQ) \
210216
STATE(IDPF_VC_CONFIG_TXQ_ERR) \
211217
STATE(IDPF_VC_CONFIG_RXQ) \
212218
STATE(IDPF_VC_CONFIG_RXQ_ERR) \
219+
STATE(IDPF_VC_ENA_QUEUES) \
220+
STATE(IDPF_VC_ENA_QUEUES_ERR) \
221+
STATE(IDPF_VC_DIS_QUEUES) \
222+
STATE(IDPF_VC_DIS_QUEUES_ERR) \
223+
STATE(IDPF_VC_MAP_IRQ) \
224+
STATE(IDPF_VC_MAP_IRQ_ERR) \
225+
STATE(IDPF_VC_UNMAP_IRQ) \
226+
STATE(IDPF_VC_UNMAP_IRQ_ERR) \
213227
STATE(IDPF_VC_ALLOC_VECTORS) \
214228
STATE(IDPF_VC_ALLOC_VECTORS_ERR) \
215229
STATE(IDPF_VC_DEALLOC_VECTORS) \
@@ -272,8 +286,10 @@ extern const char * const idpf_vport_vc_state_str[];
272286
* @base_rxd: True if the driver should use base descriptors instead of flex
273287
* @num_q_vectors: Number of IRQ vectors allocated
274288
* @q_vectors: Array of queue vectors
289+
* @q_vector_idxs: Starting index of queue vectors
275290
* @max_mtu: device given max possible MTU
276291
* @default_mac_addr: device will give a default MAC to use
292+
* @link_up: True if link is up
277293
* @vc_msg: Virtchnl message buffer
278294
* @vc_state: Virtchnl message state
279295
* @vchnl_wq: Wait queue for virtchnl messages
@@ -310,9 +326,12 @@ struct idpf_vport {
310326

311327
u16 num_q_vectors;
312328
struct idpf_q_vector *q_vectors;
329+
u16 *q_vector_idxs;
313330
u16 max_mtu;
314331
u8 default_mac_addr[ETH_ALEN];
315332

333+
bool link_up;
334+
316335
char vc_msg[IDPF_CTLQ_MAX_BUF_LEN];
317336
DECLARE_BITMAP(vc_state, IDPF_VC_NBITS);
318337

@@ -391,6 +410,22 @@ struct idpf_avail_queue_info {
391410
u16 avail_complq;
392411
};
393412

413+
/**
414+
* struct idpf_vector_info - Utility structure to pass function arguments as a
415+
* structure
416+
* @num_req_vecs: Vectors required based on the number of queues updated by the
417+
* user via ethtool
418+
* @num_curr_vecs: Current number of vectors, must be >= @num_req_vecs
419+
* @index: Relative starting index for vectors
420+
* @default_vport: Vectors are for default vport
421+
*/
422+
struct idpf_vector_info {
423+
u16 num_req_vecs;
424+
u16 num_curr_vecs;
425+
u16 index;
426+
bool default_vport;
427+
};
428+
394429
/**
395430
* struct idpf_vector_lifo - Stack to maintain vector indexes used for vector
396431
* distribution algorithm
@@ -748,13 +783,20 @@ int idpf_vc_core_init(struct idpf_adapter *adapter);
748783
void idpf_vc_core_deinit(struct idpf_adapter *adapter);
749784
int idpf_intr_req(struct idpf_adapter *adapter);
750785
void idpf_intr_rel(struct idpf_adapter *adapter);
786+
int idpf_get_reg_intr_vecs(struct idpf_vport *vport,
787+
struct idpf_vec_regs *reg_vals);
788+
int idpf_send_enable_vport_msg(struct idpf_vport *vport);
789+
int idpf_send_disable_vport_msg(struct idpf_vport *vport);
751790
int idpf_send_destroy_vport_msg(struct idpf_vport *vport);
752791
int idpf_send_get_rx_ptype_msg(struct idpf_vport *vport);
753792
int idpf_send_get_set_rss_key_msg(struct idpf_vport *vport, bool get);
754793
int idpf_send_get_set_rss_lut_msg(struct idpf_vport *vport, bool get);
755794
int idpf_send_dealloc_vectors_msg(struct idpf_adapter *adapter);
756795
int idpf_send_alloc_vectors_msg(struct idpf_adapter *adapter, u16 num_vectors);
757796
void idpf_deinit_task(struct idpf_adapter *adapter);
797+
int idpf_req_rel_vector_indexes(struct idpf_adapter *adapter,
798+
u16 *q_vector_idxs,
799+
struct idpf_vector_info *vec_info);
758800
int idpf_get_vec_ids(struct idpf_adapter *adapter,
759801
u16 *vecids, int num_vecids,
760802
struct virtchnl2_vector_chunks *chunks);
@@ -769,13 +811,16 @@ void idpf_vport_dealloc_max_qs(struct idpf_adapter *adapter,
769811
int idpf_add_del_mac_filters(struct idpf_vport *vport,
770812
struct idpf_netdev_priv *np,
771813
bool add, bool async);
814+
int idpf_send_disable_queues_msg(struct idpf_vport *vport);
772815
void idpf_vport_init(struct idpf_vport *vport, struct idpf_vport_max_q *max_q);
773816
u32 idpf_get_vport_id(struct idpf_vport *vport);
774817
int idpf_vport_queue_ids_init(struct idpf_vport *vport);
775818
int idpf_queue_reg_init(struct idpf_vport *vport);
776819
int idpf_send_config_queues_msg(struct idpf_vport *vport);
820+
int idpf_send_enable_queues_msg(struct idpf_vport *vport);
777821
int idpf_send_create_vport_msg(struct idpf_adapter *adapter,
778822
struct idpf_vport_max_q *max_q);
779823
int idpf_check_supported_desc_ids(struct idpf_vport *vport);
824+
int idpf_send_map_unmap_queue_vector_msg(struct idpf_vport *vport, bool map);
780825

781826
#endif /* !_IDPF_H_ */

drivers/net/ethernet/intel/idpf/idpf_dev.c

Lines changed: 58 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,8 @@
44
#include "idpf.h"
55
#include "idpf_lan_pf_regs.h"
66

7+
#define IDPF_PF_ITR_IDX_SPACING 0x4
8+
79
/**
810
* idpf_ctlq_reg_init - initialize default mailbox registers
911
* @cq: pointer to the array of create control queues
@@ -60,6 +62,61 @@ static void idpf_mb_intr_reg_init(struct idpf_adapter *adapter)
6062
intr->icr_ena_ctlq_m = PF_INT_DIR_OICR_ENA_M;
6163
}
6264

65+
/**
66+
* idpf_intr_reg_init - Initialize interrupt registers
67+
* @vport: virtual port structure
68+
*/
69+
static int idpf_intr_reg_init(struct idpf_vport *vport)
70+
{
71+
struct idpf_adapter *adapter = vport->adapter;
72+
int num_vecs = vport->num_q_vectors;
73+
struct idpf_vec_regs *reg_vals;
74+
int num_regs, i, err = 0;
75+
u32 rx_itr, tx_itr;
76+
u16 total_vecs;
77+
78+
total_vecs = idpf_get_reserved_vecs(vport->adapter);
79+
reg_vals = kcalloc(total_vecs, sizeof(struct idpf_vec_regs),
80+
GFP_KERNEL);
81+
if (!reg_vals)
82+
return -ENOMEM;
83+
84+
num_regs = idpf_get_reg_intr_vecs(vport, reg_vals);
85+
if (num_regs < num_vecs) {
86+
err = -EINVAL;
87+
goto free_reg_vals;
88+
}
89+
90+
for (i = 0; i < num_vecs; i++) {
91+
struct idpf_q_vector *q_vector = &vport->q_vectors[i];
92+
u16 vec_id = vport->q_vector_idxs[i] - IDPF_MBX_Q_VEC;
93+
struct idpf_intr_reg *intr = &q_vector->intr_reg;
94+
u32 spacing;
95+
96+
intr->dyn_ctl = idpf_get_reg_addr(adapter,
97+
reg_vals[vec_id].dyn_ctl_reg);
98+
intr->dyn_ctl_intena_m = PF_GLINT_DYN_CTL_INTENA_M;
99+
intr->dyn_ctl_itridx_s = PF_GLINT_DYN_CTL_ITR_INDX_S;
100+
intr->dyn_ctl_intrvl_s = PF_GLINT_DYN_CTL_INTERVAL_S;
101+
102+
spacing = IDPF_ITR_IDX_SPACING(reg_vals[vec_id].itrn_index_spacing,
103+
IDPF_PF_ITR_IDX_SPACING);
104+
rx_itr = PF_GLINT_ITR_ADDR(VIRTCHNL2_ITR_IDX_0,
105+
reg_vals[vec_id].itrn_reg,
106+
spacing);
107+
tx_itr = PF_GLINT_ITR_ADDR(VIRTCHNL2_ITR_IDX_1,
108+
reg_vals[vec_id].itrn_reg,
109+
spacing);
110+
intr->rx_itr = idpf_get_reg_addr(adapter, rx_itr);
111+
intr->tx_itr = idpf_get_reg_addr(adapter, tx_itr);
112+
}
113+
114+
free_reg_vals:
115+
kfree(reg_vals);
116+
117+
return err;
118+
}
119+
63120
/**
64121
* idpf_reset_reg_init - Initialize reset registers
65122
* @adapter: Driver specific private structure
@@ -92,6 +149,7 @@ static void idpf_trigger_reset(struct idpf_adapter *adapter,
92149
static void idpf_reg_ops_init(struct idpf_adapter *adapter)
93150
{
94151
adapter->dev_ops.reg_ops.ctlq_reg_init = idpf_ctlq_reg_init;
152+
adapter->dev_ops.reg_ops.intr_reg_init = idpf_intr_reg_init;
95153
adapter->dev_ops.reg_ops.mb_intr_reg_init = idpf_mb_intr_reg_init;
96154
adapter->dev_ops.reg_ops.reset_reg_init = idpf_reset_reg_init;
97155
adapter->dev_ops.reg_ops.trigger_reset = idpf_trigger_reset;

drivers/net/ethernet/intel/idpf/idpf_lan_pf_regs.h

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,17 @@
7474
#define PF_GLINT_DYN_CTL_WB_ON_ITR_M BIT(PF_GLINT_DYN_CTL_WB_ON_ITR_S)
7575
#define PF_GLINT_DYN_CTL_INTENA_MSK_S 31
7676
#define PF_GLINT_DYN_CTL_INTENA_MSK_M BIT(PF_GLINT_DYN_CTL_INTENA_MSK_S)
77+
/* _ITR is ITR index, _INT is interrupt index, _itrn_indx_spacing is
78+
* spacing b/w itrn registers of the same vector.
79+
*/
80+
#define PF_GLINT_ITR_ADDR(_ITR, _reg_start, _itrn_indx_spacing) \
81+
((_reg_start) + ((_ITR) * (_itrn_indx_spacing)))
82+
/* For PF, itrn_indx_spacing is 4 and itrn_reg_spacing is 0x1000 */
83+
#define PF_GLINT_ITR(_ITR, _INT) \
84+
(PF_GLINT_BASE + (((_ITR) + 1) * 4) + ((_INT) * 0x1000))
85+
#define PF_GLINT_ITR_MAX_INDEX 2
86+
#define PF_GLINT_ITR_INTERVAL_S 0
87+
#define PF_GLINT_ITR_INTERVAL_M GENMASK(11, 0)
7788

7889
/* Generic registers */
7990
#define PF_INT_DIR_OICR_ENA 0x08406000

drivers/net/ethernet/intel/idpf/idpf_lan_vf_regs.h

Lines changed: 25 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -88,6 +88,31 @@
8888
#define VF_INT_DYN_CTLN_WB_ON_ITR_M BIT(VF_INT_DYN_CTLN_WB_ON_ITR_S)
8989
#define VF_INT_DYN_CTLN_INTENA_MSK_S 31
9090
#define VF_INT_DYN_CTLN_INTENA_MSK_M BIT(VF_INT_DYN_CTLN_INTENA_MSK_S)
91+
/* _ITR is ITR index, _INT is interrupt index, _itrn_indx_spacing is spacing
92+
* b/w itrn registers of the same vector
93+
*/
94+
#define VF_INT_ITR0(_ITR) (0x00004C00 + ((_ITR) * 4))
95+
#define VF_INT_ITRN_ADDR(_ITR, _reg_start, _itrn_indx_spacing) \
96+
((_reg_start) + ((_ITR) * (_itrn_indx_spacing)))
97+
/* For VF with 16 vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing
98+
* is 0x40 and base register offset is 0x00002800
99+
*/
100+
#define VF_INT_ITRN(_INT, _ITR) \
101+
(0x00002800 + ((_INT) * 4) + ((_ITR) * 0x40))
102+
/* For VF with 64 vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing
103+
* is 0x100 and base register offset is 0x00002C00
104+
*/
105+
#define VF_INT_ITRN_64(_INT, _ITR) \
106+
(0x00002C00 + ((_INT) * 4) + ((_ITR) * 0x100))
107+
/* For VF with 2k vector support, itrn_reg_spacing is 0x4, itrn_indx_spacing
108+
* is 0x2000 and base register offset is 0x00072000
109+
*/
110+
#define VF_INT_ITRN_2K(_INT, _ITR) \
111+
(0x00072000 + ((_INT) * 4) + ((_ITR) * 0x2000))
112+
#define VF_INT_ITRN_MAX_INDEX 2
113+
#define VF_INT_ITRN_INTERVAL_S 0
114+
#define VF_INT_ITRN_INTERVAL_M GENMASK(11, 0)
115+
#define VF_INT_PBA_CLEAR 0x00008900
91116

92117
#define VF_INT_ICR0_ENA1 0x00005000
93118
#define VF_INT_ICR0_ENA1_ADMINQ_S 30

0 commit comments

Comments
 (0)