Skip to content

Commit 32a47e7

Browse files
Yuval Mintzdavem330
authored andcommitted
qed: Add CONFIG_QED_SRIOV
Add support for a new Kconfig option for qed* driver which would allow [eventually] the support in VFs. This patch adds the necessary logic in the PF to learn about the possible VFs it will have to support [Based on PCI configuration space and HW], and prepare a database with an entry per-VF as infrastructure for future interaction with said VFs. Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 631ad4a commit 32a47e7

File tree

9 files changed

+650
-0
lines changed

9 files changed

+650
-0
lines changed

drivers/net/ethernet/qlogic/Kconfig

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -98,6 +98,16 @@ config QED
9898
---help---
9999
This enables the support for ...
100100

101+
config QED_SRIOV
102+
bool "QLogic QED 25/40/100Gb SR-IOV support"
103+
depends on QED && PCI_IOV
104+
default y
105+
---help---
106+
This configuration parameter enables Single Root Input Output
107+
Virtualization support for QED devices.
108+
This allows for virtual function acceleration in virtualized
109+
environments.
110+
101111
config QEDE
102112
tristate "QLogic QED 25/40/100Gb Ethernet NIC"
103113
depends on QED

drivers/net/ethernet/qlogic/qed/Makefile

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -3,3 +3,4 @@ obj-$(CONFIG_QED) := qed.o
33
qed-y := qed_cxt.o qed_dev.o qed_hw.o qed_init_fw_funcs.o qed_init_ops.o \
44
qed_int.o qed_main.o qed_mcp.o qed_sp_commands.o qed_spq.o qed_l2.o \
55
qed_selftest.o
6+
qed-$(CONFIG_QED_SRIOV) += qed_sriov.o

drivers/net/ethernet/qlogic/qed/qed.h

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -152,6 +152,7 @@ enum QED_RESOURCES {
152152

153153
enum QED_FEATURE {
154154
QED_PF_L2_QUE,
155+
QED_VF,
155156
QED_MAX_FEATURES,
156157
};
157158

@@ -360,6 +361,7 @@ struct qed_hwfn {
360361
/* True if the driver requests for the link */
361362
bool b_drv_link_init;
362363

364+
struct qed_pf_iov *pf_iov_info;
363365
struct qed_mcp_info *mcp_info;
364366

365367
struct qed_hw_cid_data *p_tx_cids;
@@ -484,6 +486,10 @@ struct qed_dev {
484486
u8 num_hwfns;
485487
struct qed_hwfn hwfns[MAX_HWFNS_PER_DEVICE];
486488

489+
/* SRIOV */
490+
struct qed_hw_sriov_info *p_iov_info;
491+
#define IS_QED_SRIOV(cdev) (!!(cdev)->p_iov_info)
492+
487493
unsigned long tunn_mode;
488494
u32 drv_type;
489495

@@ -514,6 +520,7 @@ struct qed_dev {
514520
const struct firmware *firmware;
515521
};
516522

523+
#define NUM_OF_VFS(dev) MAX_NUM_VFS_BB
517524
#define NUM_OF_SBS(dev) MAX_SB_PER_PATH_BB
518525
#define NUM_OF_ENG_PFS(dev) MAX_NUM_PFS_BB
519526

drivers/net/ethernet/qlogic/qed/qed_dev.c

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -30,6 +30,7 @@
3030
#include "qed_mcp.h"
3131
#include "qed_reg_addr.h"
3232
#include "qed_sp.h"
33+
#include "qed_sriov.h"
3334

3435
/* API common to all protocols */
3536
enum BAR_ID {
@@ -136,6 +137,7 @@ void qed_resc_free(struct qed_dev *cdev)
136137
qed_eq_free(p_hwfn, p_hwfn->p_eq);
137138
qed_consq_free(p_hwfn, p_hwfn->p_consq);
138139
qed_int_free(p_hwfn);
140+
qed_iov_free(p_hwfn);
139141
qed_dmae_info_free(p_hwfn);
140142
}
141143
}
@@ -316,6 +318,10 @@ int qed_resc_alloc(struct qed_dev *cdev)
316318
if (rc)
317319
goto alloc_err;
318320

321+
rc = qed_iov_alloc(p_hwfn);
322+
if (rc)
323+
goto alloc_err;
324+
319325
/* EQ */
320326
p_eq = qed_eq_alloc(p_hwfn, 256);
321327
if (!p_eq) {
@@ -373,6 +379,8 @@ void qed_resc_setup(struct qed_dev *cdev)
373379
p_hwfn->mcp_info->mfw_mb_length);
374380

375381
qed_int_setup(p_hwfn, p_hwfn->p_main_ptt);
382+
383+
qed_iov_setup(p_hwfn, p_hwfn->p_main_ptt);
376384
}
377385
}
378386

@@ -1238,6 +1246,13 @@ qed_get_hw_info(struct qed_hwfn *p_hwfn,
12381246
u32 port_mode;
12391247
int rc;
12401248

1249+
/* Since all information is common, only first hwfns should do this */
1250+
if (IS_LEAD_HWFN(p_hwfn)) {
1251+
rc = qed_iov_hw_info(p_hwfn);
1252+
if (rc)
1253+
return rc;
1254+
}
1255+
12411256
/* Read the port mode */
12421257
port_mode = qed_rd(p_hwfn, p_ptt,
12431258
CNIG_REG_NW_PORT_MODE_BB_B0);
@@ -1397,6 +1412,8 @@ static int qed_hw_prepare_single(struct qed_hwfn *p_hwfn,
13971412

13981413
return rc;
13991414
err2:
1415+
if (IS_LEAD_HWFN(p_hwfn))
1416+
qed_iov_free_hw_info(p_hwfn->cdev);
14001417
qed_mcp_free(p_hwfn);
14011418
err1:
14021419
qed_hw_hwfn_free(p_hwfn);
@@ -1463,6 +1480,8 @@ void qed_hw_remove(struct qed_dev *cdev)
14631480
qed_hw_hwfn_free(p_hwfn);
14641481
qed_mcp_free(p_hwfn);
14651482
}
1483+
1484+
qed_iov_free_hw_info(cdev);
14661485
}
14671486

14681487
int qed_chain_alloc(struct qed_dev *cdev,

drivers/net/ethernet/qlogic/qed/qed_hw.c

Lines changed: 11 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -338,6 +338,17 @@ void qed_port_unpretend(struct qed_hwfn *p_hwfn,
338338
*(u32 *)&p_ptt->pxp.pretend);
339339
}
340340

341+
u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid)
342+
{
343+
u32 concrete_fid = 0;
344+
345+
SET_FIELD(concrete_fid, PXP_CONCRETE_FID_PFID, p_hwfn->rel_pf_id);
346+
SET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFID, vfid);
347+
SET_FIELD(concrete_fid, PXP_CONCRETE_FID_VFVALID, 1);
348+
349+
return concrete_fid;
350+
}
351+
341352
/* DMAE */
342353
static void qed_dmae_opcode(struct qed_hwfn *p_hwfn,
343354
const u8 is_src_type_grc,

drivers/net/ethernet/qlogic/qed/qed_hw.h

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -220,6 +220,16 @@ void qed_port_pretend(struct qed_hwfn *p_hwfn,
220220
void qed_port_unpretend(struct qed_hwfn *p_hwfn,
221221
struct qed_ptt *p_ptt);
222222

223+
/**
224+
* @brief qed_vfid_to_concrete - build a concrete FID for a
225+
* given VF ID
226+
*
227+
* @param p_hwfn
228+
* @param p_ptt
229+
* @param vfid
230+
*/
231+
u32 qed_vfid_to_concrete(struct qed_hwfn *p_hwfn, u8 vfid);
232+
223233
/**
224234
* @brief qed_dmae_idx_to_go_cmd - map the idx to dmae cmd
225235
* this is declared here since other files will require it.

0 commit comments

Comments
 (0)