Skip to content

Commit 0b55e27

Browse files
Yuval Mintzdavem330
authored andcommitted
qed: IOV configure and FLR
While previous patches have already added the necessary logic to probe VFs as well as enabling them in the HW, this patch adds the ability to support VF FLR & SRIOV disable. It then wraps both flows together into the first IOV callback to be provided to the protocol driver - `configure'. This would later to be used to enable and disable SRIOV in the adapter. Signed-off-by: Yuval Mintz <[email protected]> Signed-off-by: David S. Miller <[email protected]>
1 parent 1408cc1 commit 0b55e27

File tree

15 files changed

+983
-11
lines changed

15 files changed

+983
-11
lines changed

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

Lines changed: 11 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@
3131
#include "qed_reg_addr.h"
3232
#include "qed_sp.h"
3333
#include "qed_sriov.h"
34+
#include "qed_vf.h"
3435

3536
/* API common to all protocols */
3637
enum BAR_ID {
@@ -420,15 +421,17 @@ void qed_resc_setup(struct qed_dev *cdev)
420421
#define FINAL_CLEANUP_POLL_CNT (100)
421422
#define FINAL_CLEANUP_POLL_TIME (10)
422423
int qed_final_cleanup(struct qed_hwfn *p_hwfn,
423-
struct qed_ptt *p_ptt,
424-
u16 id)
424+
struct qed_ptt *p_ptt, u16 id, bool is_vf)
425425
{
426426
u32 command = 0, addr, count = FINAL_CLEANUP_POLL_CNT;
427427
int rc = -EBUSY;
428428

429429
addr = GTT_BAR0_MAP_REG_USDM_RAM +
430430
USTORM_FLR_FINAL_ACK_OFFSET(p_hwfn->rel_pf_id);
431431

432+
if (is_vf)
433+
id += 0x10;
434+
432435
command |= X_FINAL_CLEANUP_AGG_INT <<
433436
SDM_AGG_INT_COMP_PARAMS_AGG_INT_INDEX_SHIFT;
434437
command |= 1 << SDM_AGG_INT_COMP_PARAMS_AGG_VECTOR_ENABLE_SHIFT;
@@ -663,7 +666,7 @@ static int qed_hw_init_pf(struct qed_hwfn *p_hwfn,
663666
STORE_RT_REG(p_hwfn, PRS_REG_SEARCH_ROCE_RT_OFFSET, 0);
664667

665668
/* Cleanup chip from previous driver if such remains exist */
666-
rc = qed_final_cleanup(p_hwfn, p_ptt, rel_pf_id);
669+
rc = qed_final_cleanup(p_hwfn, p_ptt, rel_pf_id, false);
667670
if (rc != 0)
668671
return rc;
669672

@@ -880,7 +883,7 @@ int qed_hw_stop(struct qed_dev *cdev)
880883
DP_VERBOSE(p_hwfn, NETIF_MSG_IFDOWN, "Stopping hw/fw\n");
881884

882885
if (IS_VF(cdev)) {
883-
/* To be implemented in a later patch */
886+
qed_vf_pf_int_cleanup(p_hwfn);
884887
continue;
885888
}
886889

@@ -989,7 +992,9 @@ int qed_hw_reset(struct qed_dev *cdev)
989992
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
990993

991994
if (IS_VF(cdev)) {
992-
/* Will be implemented in a later patch */
995+
rc = qed_vf_pf_reset(p_hwfn);
996+
if (rc)
997+
return rc;
993998
continue;
994999
}
9951000

@@ -1590,7 +1595,7 @@ void qed_hw_remove(struct qed_dev *cdev)
15901595
struct qed_hwfn *p_hwfn = &cdev->hwfns[i];
15911596

15921597
if (IS_VF(cdev)) {
1593-
/* Will be implemented in a later patch */
1598+
qed_vf_pf_release(p_hwfn);
15941599
continue;
15951600
}
15961601

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

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -303,11 +303,11 @@ int qed_fw_rss_eng(struct qed_hwfn *p_hwfn,
303303
* @param p_hwfn
304304
* @param p_ptt
305305
* @param id - For PF, engine-relative. For VF, PF-relative.
306+
* @param is_vf - true iff cleanup is made for a VF.
306307
*
307308
* @return int
308309
*/
309310
int qed_final_cleanup(struct qed_hwfn *p_hwfn,
310-
struct qed_ptt *p_ptt,
311-
u16 id);
311+
struct qed_ptt *p_ptt, u16 id, bool is_vf);
312312

313313
#endif

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

Lines changed: 9 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -30,7 +30,7 @@ enum common_event_opcode {
3030
COMMON_EVENT_PF_START,
3131
COMMON_EVENT_PF_STOP,
3232
COMMON_EVENT_VF_START,
33-
COMMON_EVENT_RESERVED2,
33+
COMMON_EVENT_VF_STOP,
3434
COMMON_EVENT_VF_PF_CHANNEL,
3535
COMMON_EVENT_RESERVED4,
3636
COMMON_EVENT_RESERVED5,
@@ -45,7 +45,7 @@ enum common_ramrod_cmd_id {
4545
COMMON_RAMROD_PF_START /* PF Function Start Ramrod */,
4646
COMMON_RAMROD_PF_STOP /* PF Function Stop Ramrod */,
4747
COMMON_RAMROD_VF_START,
48-
COMMON_RAMROD_RESERVED2,
48+
COMMON_RAMROD_VF_STOP,
4949
COMMON_RAMROD_PF_UPDATE,
5050
COMMON_RAMROD_EMPTY,
5151
MAX_COMMON_RAMROD_CMD_ID
@@ -741,6 +741,13 @@ struct vf_start_ramrod_data {
741741
u8 reserved[3];
742742
};
743743

744+
struct vf_stop_ramrod_data {
745+
u8 vf_id;
746+
u8 reserved0;
747+
__le16 reserved1;
748+
__le32 reserved2;
749+
};
750+
744751
struct atten_status_block {
745752
__le32 atten_bits;
746753
__le32 atten_ack;

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

Lines changed: 7 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -2066,8 +2066,15 @@ static int qed_fp_cqe_completion(struct qed_dev *dev,
20662066
cqe);
20672067
}
20682068

2069+
#ifdef CONFIG_QED_SRIOV
2070+
extern const struct qed_iov_hv_ops qed_iov_ops_pass;
2071+
#endif
2072+
20692073
static const struct qed_eth_ops qed_eth_ops_pass = {
20702074
.common = &qed_common_ops_pass,
2075+
#ifdef CONFIG_QED_SRIOV
2076+
.iov = &qed_iov_ops_pass,
2077+
#endif
20712078
.fill_dev_info = &qed_fill_eth_dev_info,
20722079
.register_ops = &qed_register_eth_ops,
20732080
.vport_start = &qed_start_vport,

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -897,6 +897,7 @@ static int qed_slowpath_stop(struct qed_dev *cdev)
897897

898898
if (IS_PF(cdev)) {
899899
qed_free_stream_mem(cdev);
900+
qed_sriov_disable(cdev, true);
900901

901902
qed_nic_stop(cdev);
902903
qed_slowpath_irq_free(cdev);

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

Lines changed: 72 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -442,6 +442,75 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
442442
return 0;
443443
}
444444

445+
static void qed_mcp_handle_vf_flr(struct qed_hwfn *p_hwfn,
446+
struct qed_ptt *p_ptt)
447+
{
448+
u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base,
449+
PUBLIC_PATH);
450+
u32 mfw_path_offsize = qed_rd(p_hwfn, p_ptt, addr);
451+
u32 path_addr = SECTION_ADDR(mfw_path_offsize,
452+
QED_PATH_ID(p_hwfn));
453+
u32 disabled_vfs[VF_MAX_STATIC / 32];
454+
int i;
455+
456+
DP_VERBOSE(p_hwfn,
457+
QED_MSG_SP,
458+
"Reading Disabled VF information from [offset %08x], path_addr %08x\n",
459+
mfw_path_offsize, path_addr);
460+
461+
for (i = 0; i < (VF_MAX_STATIC / 32); i++) {
462+
disabled_vfs[i] = qed_rd(p_hwfn, p_ptt,
463+
path_addr +
464+
offsetof(struct public_path,
465+
mcp_vf_disabled) +
466+
sizeof(u32) * i);
467+
DP_VERBOSE(p_hwfn, (QED_MSG_SP | QED_MSG_IOV),
468+
"FLR-ed VFs [%08x,...,%08x] - %08x\n",
469+
i * 32, (i + 1) * 32 - 1, disabled_vfs[i]);
470+
}
471+
472+
if (qed_iov_mark_vf_flr(p_hwfn, disabled_vfs))
473+
qed_schedule_iov(p_hwfn, QED_IOV_WQ_FLR_FLAG);
474+
}
475+
476+
int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
477+
struct qed_ptt *p_ptt, u32 *vfs_to_ack)
478+
{
479+
u32 addr = SECTION_OFFSIZE_ADDR(p_hwfn->mcp_info->public_base,
480+
PUBLIC_FUNC);
481+
u32 mfw_func_offsize = qed_rd(p_hwfn, p_ptt, addr);
482+
u32 func_addr = SECTION_ADDR(mfw_func_offsize,
483+
MCP_PF_ID(p_hwfn));
484+
struct qed_mcp_mb_params mb_params;
485+
union drv_union_data union_data;
486+
int rc;
487+
int i;
488+
489+
for (i = 0; i < (VF_MAX_STATIC / 32); i++)
490+
DP_VERBOSE(p_hwfn, (QED_MSG_SP | QED_MSG_IOV),
491+
"Acking VFs [%08x,...,%08x] - %08x\n",
492+
i * 32, (i + 1) * 32 - 1, vfs_to_ack[i]);
493+
494+
memset(&mb_params, 0, sizeof(mb_params));
495+
mb_params.cmd = DRV_MSG_CODE_VF_DISABLED_DONE;
496+
memcpy(&union_data.ack_vf_disabled, vfs_to_ack, VF_MAX_STATIC / 8);
497+
mb_params.p_data_src = &union_data;
498+
rc = qed_mcp_cmd_and_union(p_hwfn, p_ptt, &mb_params);
499+
if (rc) {
500+
DP_NOTICE(p_hwfn, "Failed to pass ACK for VF flr to MFW\n");
501+
return -EBUSY;
502+
}
503+
504+
/* Clear the ACK bits */
505+
for (i = 0; i < (VF_MAX_STATIC / 32); i++)
506+
qed_wr(p_hwfn, p_ptt,
507+
func_addr +
508+
offsetof(struct public_func, drv_ack_vf_disabled) +
509+
i * sizeof(u32), 0);
510+
511+
return rc;
512+
}
513+
445514
static void qed_mcp_handle_transceiver_change(struct qed_hwfn *p_hwfn,
446515
struct qed_ptt *p_ptt)
447516
{
@@ -753,6 +822,9 @@ int qed_mcp_handle_events(struct qed_hwfn *p_hwfn,
753822
case MFW_DRV_MSG_LINK_CHANGE:
754823
qed_mcp_handle_link_change(p_hwfn, p_ptt, false);
755824
break;
825+
case MFW_DRV_MSG_VF_DISABLED:
826+
qed_mcp_handle_vf_flr(p_hwfn, p_ptt);
827+
break;
756828
case MFW_DRV_MSG_TRANSCEIVER_STATE_CHANGE:
757829
qed_mcp_handle_transceiver_change(p_hwfn, p_ptt);
758830
break;

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

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -392,6 +392,18 @@ int qed_mcp_load_req(struct qed_hwfn *p_hwfn,
392392
void qed_mcp_read_mb(struct qed_hwfn *p_hwfn,
393393
struct qed_ptt *p_ptt);
394394

395+
/**
396+
* @brief Ack to mfw that driver finished FLR process for VFs
397+
*
398+
* @param p_hwfn
399+
* @param p_ptt
400+
* @param vfs_to_ack - bit mask of all engine VFs for which the PF acks.
401+
*
402+
* @param return int - 0 upon success.
403+
*/
404+
int qed_mcp_ack_vf_flr(struct qed_hwfn *p_hwfn,
405+
struct qed_ptt *p_ptt, u32 *vfs_to_ack);
406+
395407
/**
396408
* @brief - calls during init to read shmem of all function-related info.
397409
*

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

Lines changed: 10 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -41,6 +41,8 @@
4141
0x2aa16cUL
4242
#define PGLUE_B_REG_WAS_ERROR_VF_31_0_CLR \
4343
0x2aa118UL
44+
#define PSWHST_REG_ZONE_PERMISSION_TABLE \
45+
0x2a0800UL
4446
#define BAR0_MAP_REG_MSDM_RAM \
4547
0x1d00000UL
4648
#define BAR0_MAP_REG_USDM_RAM \
@@ -79,6 +81,8 @@
7981
0x2f2eb0UL
8082
#define DORQ_REG_PF_DB_ENABLE \
8183
0x100508UL
84+
#define DORQ_REG_VF_USAGE_CNT \
85+
0x1009c4UL
8286
#define QM_REG_PF_EN \
8387
0x2f2ea4UL
8488
#define TCFC_REG_STRONG_ENABLE_PF \
@@ -167,6 +171,10 @@
167171
0x040200UL
168172
#define PBF_REG_INIT \
169173
0xd80000UL
174+
#define PBF_REG_NUM_BLOCKS_ALLOCATED_PROD_VOQ0 \
175+
0xd806c8UL
176+
#define PBF_REG_NUM_BLOCKS_ALLOCATED_CONS_VOQ0 \
177+
0xd806ccUL
170178
#define PTU_REG_ATC_INIT_ARRAY \
171179
0x560000UL
172180
#define PCM_REG_INIT \
@@ -391,6 +399,8 @@
391399
0x1d0000UL
392400
#define IGU_REG_PF_CONFIGURATION \
393401
0x180800UL
402+
#define IGU_REG_VF_CONFIGURATION \
403+
0x180804UL
394404
#define MISC_REG_AEU_ENABLE1_IGU_OUT_0 \
395405
0x00849cUL
396406
#define MISC_REG_AEU_AFTER_INVERT_1_IGU \

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

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -64,6 +64,7 @@ union ramrod_data {
6464
struct vport_filter_update_ramrod_data vport_filter_update;
6565

6666
struct vf_start_ramrod_data vf_start;
67+
struct vf_stop_ramrod_data vf_stop;
6768
};
6869

6970
#define EQ_MAX_CREDIT 0xffffffff

0 commit comments

Comments
 (0)