Skip to content

Commit 0bc5fe8

Browse files
Sudarsana Reddy Kallurudavem330
authored andcommitted
qed*: Refactor mf_mode to consist of bits.
`mf_mode' field indicates the multi-partitioning mode the device is configured to. This method doesn't scale very well, adding a new MF mode requires going over all the existing conditions, and deciding whether those are needed for the new mode or not. The patch defines a set of bit-fields for modes which are derived according to the mode info shared by the MFW and all the configuration would be made according to those. To add a new mode, there would be a single place where we'll need to go and choose which bits apply and which don't. Signed-off-by: Sudarsana Reddy Kalluru <Sudarsana.Kalluru@cavium.com> Signed-off-by: Ariel Elior <ariel.elior@cavium.com> Signed-off-by: David S. Miller <davem@davemloft.net>
1 parent 3a443bd commit 0bc5fe8

8 files changed

Lines changed: 71 additions & 46 deletions

File tree

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

Lines changed: 37 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -439,6 +439,41 @@ struct qed_fw_data {
439439
u32 init_ops_size;
440440
};
441441

442+
enum qed_mf_mode_bit {
443+
/* Supports PF-classification based on tag */
444+
QED_MF_OVLAN_CLSS,
445+
446+
/* Supports PF-classification based on MAC */
447+
QED_MF_LLH_MAC_CLSS,
448+
449+
/* Supports PF-classification based on protocol type */
450+
QED_MF_LLH_PROTO_CLSS,
451+
452+
/* Requires a default PF to be set */
453+
QED_MF_NEED_DEF_PF,
454+
455+
/* Allow LL2 to multicast/broadcast */
456+
QED_MF_LL2_NON_UNICAST,
457+
458+
/* Allow Cross-PF [& child VFs] Tx-switching */
459+
QED_MF_INTER_PF_SWITCH,
460+
461+
/* Unified Fabtic Port support enabled */
462+
QED_MF_UFP_SPECIFIC,
463+
464+
/* Disable Accelerated Receive Flow Steering (aRFS) */
465+
QED_MF_DISABLE_ARFS,
466+
467+
/* Use vlan for steering */
468+
QED_MF_8021Q_TAGGING,
469+
470+
/* Use stag for steering */
471+
QED_MF_8021AD_TAGGING,
472+
473+
/* Allow DSCP to TC mapping */
474+
QED_MF_DSCP_TO_TC_MAP,
475+
};
476+
442477
enum BAR_ID {
443478
BAR_ID_0, /* used for GRC */
444479
BAR_ID_1 /* Used for doorbells */
@@ -669,10 +704,8 @@ struct qed_dev {
669704
u8 num_funcs_in_port;
670705

671706
u8 path_id;
672-
enum qed_mf_mode mf_mode;
673-
#define IS_MF_DEFAULT(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_DEFAULT)
674-
#define IS_MF_SI(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_NPAR)
675-
#define IS_MF_SD(_p_hwfn) (((_p_hwfn)->cdev)->mf_mode == QED_MF_OVLAN)
707+
708+
unsigned long mf_bits;
676709

677710
int pcie_width;
678711
int pcie_speed;

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

Lines changed: 19 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1149,18 +1149,10 @@ static int qed_calc_hw_mode(struct qed_hwfn *p_hwfn)
11491149
return -EINVAL;
11501150
}
11511151

1152-
switch (p_hwfn->cdev->mf_mode) {
1153-
case QED_MF_DEFAULT:
1154-
case QED_MF_NPAR:
1155-
hw_mode |= 1 << MODE_MF_SI;
1156-
break;
1157-
case QED_MF_OVLAN:
1152+
if (test_bit(QED_MF_OVLAN_CLSS, &p_hwfn->cdev->mf_bits))
11581153
hw_mode |= 1 << MODE_MF_SD;
1159-
break;
1160-
default:
1161-
DP_NOTICE(p_hwfn, "Unsupported MF mode, init as DEFAULT\n");
1154+
else
11621155
hw_mode |= 1 << MODE_MF_SI;
1163-
}
11641156

11651157
hw_mode |= 1 << MODE_ASIC;
11661158

@@ -1557,7 +1549,6 @@ static int qed_hw_init_pf(struct qed_hwfn *p_hwfn,
15571549

15581550
/* send function start command */
15591551
rc = qed_sp_pf_start(p_hwfn, p_ptt, p_tunn,
1560-
p_hwfn->cdev->mf_mode,
15611552
allow_npar_tx_switch);
15621553
if (rc) {
15631554
DP_NOTICE(p_hwfn, "Function start ramrod failed\n");
@@ -2651,17 +2642,25 @@ static int qed_hw_get_nvm_info(struct qed_hwfn *p_hwfn, struct qed_ptt *p_ptt)
26512642

26522643
switch (mf_mode) {
26532644
case NVM_CFG1_GLOB_MF_MODE_MF_ALLOWED:
2654-
p_hwfn->cdev->mf_mode = QED_MF_OVLAN;
2645+
p_hwfn->cdev->mf_bits = BIT(QED_MF_OVLAN_CLSS);
26552646
break;
26562647
case NVM_CFG1_GLOB_MF_MODE_NPAR1_0:
2657-
p_hwfn->cdev->mf_mode = QED_MF_NPAR;
2648+
p_hwfn->cdev->mf_bits = BIT(QED_MF_LLH_MAC_CLSS) |
2649+
BIT(QED_MF_LLH_PROTO_CLSS) |
2650+
BIT(QED_MF_LL2_NON_UNICAST) |
2651+
BIT(QED_MF_INTER_PF_SWITCH);
26582652
break;
26592653
case NVM_CFG1_GLOB_MF_MODE_DEFAULT:
2660-
p_hwfn->cdev->mf_mode = QED_MF_DEFAULT;
2654+
p_hwfn->cdev->mf_bits = BIT(QED_MF_LLH_MAC_CLSS) |
2655+
BIT(QED_MF_LLH_PROTO_CLSS) |
2656+
BIT(QED_MF_LL2_NON_UNICAST);
2657+
if (QED_IS_BB(p_hwfn->cdev))
2658+
p_hwfn->cdev->mf_bits |= BIT(QED_MF_NEED_DEF_PF);
26612659
break;
26622660
}
2663-
DP_INFO(p_hwfn, "Multi function mode is %08x\n",
2664-
p_hwfn->cdev->mf_mode);
2661+
2662+
DP_INFO(p_hwfn, "Multi function mode is 0x%lx\n",
2663+
p_hwfn->cdev->mf_bits);
26652664

26662665
/* Read Multi-function information from shmem */
26672666
addr = MCP_REG_SCRATCH + nvm_cfg1_offset +
@@ -3462,7 +3461,7 @@ int qed_llh_add_mac_filter(struct qed_hwfn *p_hwfn,
34623461
u32 high = 0, low = 0, en;
34633462
int i;
34643463

3465-
if (!(IS_MF_SI(p_hwfn) || IS_MF_DEFAULT(p_hwfn)))
3464+
if (!test_bit(QED_MF_LLH_MAC_CLSS, &p_hwfn->cdev->mf_bits))
34663465
return 0;
34673466

34683467
qed_llh_mac_to_filter(&high, &low, p_filter);
@@ -3507,7 +3506,7 @@ void qed_llh_remove_mac_filter(struct qed_hwfn *p_hwfn,
35073506
u32 high = 0, low = 0;
35083507
int i;
35093508

3510-
if (!(IS_MF_SI(p_hwfn) || IS_MF_DEFAULT(p_hwfn)))
3509+
if (!test_bit(QED_MF_LLH_MAC_CLSS, &p_hwfn->cdev->mf_bits))
35113510
return;
35123511

35133512
qed_llh_mac_to_filter(&high, &low, p_filter);
@@ -3549,7 +3548,7 @@ qed_llh_add_protocol_filter(struct qed_hwfn *p_hwfn,
35493548
u32 high = 0, low = 0, en;
35503549
int i;
35513550

3552-
if (!(IS_MF_SI(p_hwfn) || IS_MF_DEFAULT(p_hwfn)))
3551+
if (!test_bit(QED_MF_LLH_PROTO_CLSS, &p_hwfn->cdev->mf_bits))
35533552
return 0;
35543553

35553554
switch (type) {
@@ -3647,7 +3646,7 @@ qed_llh_remove_protocol_filter(struct qed_hwfn *p_hwfn,
36473646
u32 high = 0, low = 0;
36483647
int i;
36493648

3650-
if (!(IS_MF_SI(p_hwfn) || IS_MF_DEFAULT(p_hwfn)))
3649+
if (!test_bit(QED_MF_LLH_PROTO_CLSS, &p_hwfn->cdev->mf_bits))
36513650
return;
36523651

36533652
switch (type) {

‎drivers/net/ethernet/qlogic/qed/qed_ll2.c‎

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -922,9 +922,9 @@ static int qed_sp_ll2_rx_queue_start(struct qed_hwfn *p_hwfn,
922922
p_ramrod->queue_id = p_ll2_conn->queue_id;
923923
p_ramrod->main_func_queue = p_ll2_conn->main_func_queue ? 1 : 0;
924924

925-
if ((IS_MF_DEFAULT(p_hwfn) || IS_MF_SI(p_hwfn)) &&
926-
p_ramrod->main_func_queue && (conn_type != QED_LL2_TYPE_ROCE) &&
927-
(conn_type != QED_LL2_TYPE_IWARP)) {
925+
if (test_bit(QED_MF_LL2_NON_UNICAST, &p_hwfn->cdev->mf_bits) &&
926+
p_ramrod->main_func_queue && conn_type != QED_LL2_TYPE_ROCE &&
927+
conn_type != QED_LL2_TYPE_IWARP) {
928928
p_ramrod->mf_si_bcast_accept_all = 1;
929929
p_ramrod->mf_si_mcast_accept_all = 1;
930930
} else {

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

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -264,7 +264,8 @@ int qed_fill_dev_info(struct qed_dev *cdev,
264264
dev_info->pci_mem_end = cdev->pci_params.mem_end;
265265
dev_info->pci_irq = cdev->pci_params.irq;
266266
dev_info->rdma_supported = QED_IS_RDMA_PERSONALITY(p_hwfn);
267-
dev_info->is_mf_default = IS_MF_DEFAULT(&cdev->hwfns[0]);
267+
dev_info->is_mf_default = !test_bit(QED_MF_LLH_MAC_CLSS,
268+
&cdev->mf_bits);
268269
dev_info->dev_type = cdev->type;
269270
ether_addr_copy(dev_info->hw_mac, hw_info->hw_mac_addr);
270271

@@ -273,7 +274,8 @@ int qed_fill_dev_info(struct qed_dev *cdev,
273274
dev_info->fw_minor = FW_MINOR_VERSION;
274275
dev_info->fw_rev = FW_REVISION_VERSION;
275276
dev_info->fw_eng = FW_ENGINEERING_VERSION;
276-
dev_info->mf_mode = cdev->mf_mode;
277+
dev_info->b_inter_pf_switch = test_bit(QED_MF_INTER_PF_SWITCH,
278+
&cdev->mf_bits);
277279
dev_info->tx_switching = true;
278280

279281
if (hw_info->b_wol_support == QED_WOL_SUPPORT_PME)

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

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -416,7 +416,6 @@ int qed_sp_init_request(struct qed_hwfn *p_hwfn,
416416
* @param p_hwfn
417417
* @param p_ptt
418418
* @param p_tunn
419-
* @param mode
420419
* @param allow_npar_tx_switch
421420
*
422421
* @return int
@@ -425,7 +424,7 @@ int qed_sp_init_request(struct qed_hwfn *p_hwfn,
425424
int qed_sp_pf_start(struct qed_hwfn *p_hwfn,
426425
struct qed_ptt *p_ptt,
427426
struct qed_tunnel_info *p_tunn,
428-
enum qed_mf_mode mode, bool allow_npar_tx_switch);
427+
bool allow_npar_tx_switch);
429428

430429
/**
431430
* @brief qed_sp_pf_update - PF Function Update Ramrod

‎drivers/net/ethernet/qlogic/qed/qed_sp_commands.c‎

Lines changed: 4 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -306,7 +306,7 @@ qed_tunn_set_pf_start_params(struct qed_hwfn *p_hwfn,
306306
int qed_sp_pf_start(struct qed_hwfn *p_hwfn,
307307
struct qed_ptt *p_ptt,
308308
struct qed_tunnel_info *p_tunn,
309-
enum qed_mf_mode mode, bool allow_npar_tx_switch)
309+
bool allow_npar_tx_switch)
310310
{
311311
struct pf_start_ramrod_data *p_ramrod = NULL;
312312
u16 sb = qed_int_get_sp_sb_id(p_hwfn);
@@ -339,18 +339,10 @@ int qed_sp_pf_start(struct qed_hwfn *p_hwfn,
339339
p_ramrod->dont_log_ramrods = 0;
340340
p_ramrod->log_type_mask = cpu_to_le16(0xf);
341341

342-
switch (mode) {
343-
case QED_MF_DEFAULT:
344-
case QED_MF_NPAR:
345-
p_ramrod->mf_mode = MF_NPAR;
346-
break;
347-
case QED_MF_OVLAN:
342+
if (test_bit(QED_MF_OVLAN_CLSS, &p_hwfn->cdev->mf_bits))
348343
p_ramrod->mf_mode = MF_OVLAN;
349-
break;
350-
default:
351-
DP_NOTICE(p_hwfn, "Unsupported MF mode, init as DEFAULT\n");
344+
else
352345
p_ramrod->mf_mode = MF_NPAR;
353-
}
354346

355347
p_ramrod->outer_tag_config.outer_tag.tci =
356348
cpu_to_le16(p_hwfn->hw_info.ovlan);
@@ -365,7 +357,7 @@ int qed_sp_pf_start(struct qed_hwfn *p_hwfn,
365357

366358
qed_tunn_set_pf_start_params(p_hwfn, p_tunn, &p_ramrod->tunnel_config);
367359

368-
if (IS_MF_SI(p_hwfn))
360+
if (test_bit(QED_MF_INTER_PF_SWITCH, &p_hwfn->cdev->mf_bits))
369361
p_ramrod->allow_npar_tx_switching = allow_npar_tx_switch;
370362

371363
switch (p_hwfn->hw_info.personality) {

‎drivers/net/ethernet/qlogic/qede/qede_main.c‎

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -199,7 +199,7 @@ static int qede_sriov_configure(struct pci_dev *pdev, int num_vfs_param)
199199

200200
/* Enable/Disable Tx switching for PF */
201201
if ((rc == num_vfs_param) && netif_running(edev->ndev) &&
202-
qed_info->mf_mode != QED_MF_NPAR && qed_info->tx_switching) {
202+
!qed_info->b_inter_pf_switch && qed_info->tx_switching) {
203203
vport_params->vport_id = 0;
204204
vport_params->update_tx_switching_flg = 1;
205205
vport_params->tx_switching_flg = num_vfs_param ? 1 : 0;
@@ -1928,7 +1928,7 @@ static int qede_start_queues(struct qede_dev *edev, bool clear_stats)
19281928
vport_update_params->update_vport_active_flg = 1;
19291929
vport_update_params->vport_active_flg = 1;
19301930

1931-
if ((qed_info->mf_mode == QED_MF_NPAR || pci_num_vf(edev->pdev)) &&
1931+
if ((qed_info->b_inter_pf_switch || pci_num_vf(edev->pdev)) &&
19321932
qed_info->tx_switching) {
19331933
vport_update_params->update_tx_switching_flg = 1;
19341934
vport_update_params->tx_switching_flg = 1;

‎include/linux/qed/qed_if.h‎

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -359,7 +359,7 @@ struct qed_dev_info {
359359
#define QED_MFW_VERSION_3_OFFSET 24
360360

361361
u32 flash_size;
362-
u8 mf_mode;
362+
bool b_inter_pf_switch;
363363
bool tx_switching;
364364
bool rdma_supported;
365365
u16 mtu;

0 commit comments

Comments
 (0)