Skip to content

Commit 58930c0

Browse files
bmarreddykuba-moo
authored andcommitted
bng_en: Register default VNIC
Allocate the default VNIC with the firmware and configure its RSS, HDS, and Jumbo parameters. Add related functions to support VNIC configuration for these parameters. Signed-off-by: Bhargava Marreddy <[email protected]> Reviewed-by: Vikas Gupta <[email protected]> Reviewed-by: Rajashekar Hudumula <[email protected]> Link: https://patch.msgid.link/[email protected] Signed-off-by: Jakub Kicinski <[email protected]>
1 parent c757ef3 commit 58930c0

File tree

8 files changed

+368
-2
lines changed

8 files changed

+368
-2
lines changed

drivers/net/ethernet/broadcom/bnge/bnge.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -160,6 +160,7 @@ struct bnge_dev {
160160
u16 rss_indir_tbl_entries;
161161

162162
u32 rss_cap;
163+
u32 rss_hash_cfg;
163164

164165
u16 rx_nr_rings;
165166
u16 tx_nr_rings;

drivers/net/ethernet/broadcom/bnge/bnge_core.c

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -96,6 +96,16 @@ static void bnge_fw_unregister_dev(struct bnge_dev *bd)
9696
bnge_free_ctx_mem(bd);
9797
}
9898

99+
static void bnge_set_dflt_rss_hash_type(struct bnge_dev *bd)
100+
{
101+
bd->rss_hash_cfg = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 |
102+
VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4 |
103+
VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6 |
104+
VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6 |
105+
VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV4 |
106+
VNIC_RSS_CFG_REQ_HASH_TYPE_UDP_IPV6;
107+
}
108+
99109
static int bnge_fw_register_dev(struct bnge_dev *bd)
100110
{
101111
int rc;
@@ -137,6 +147,8 @@ static int bnge_fw_register_dev(struct bnge_dev *bd)
137147
goto err_func_unrgtr;
138148
}
139149

150+
bnge_set_dflt_rss_hash_type(bd);
151+
140152
return 0;
141153

142154
err_func_unrgtr:

drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.c

Lines changed: 207 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -6,6 +6,8 @@
66
#include <linux/mm.h>
77
#include <linux/pci.h>
88
#include <linux/bnxt/hsi.h>
9+
#include <linux/if_vlan.h>
10+
#include <net/netdev_queues.h>
911

1012
#include "bnge.h"
1113
#include "bnge_hwrm.h"
@@ -702,6 +704,211 @@ int bnge_hwrm_queue_qportcfg(struct bnge_dev *bd)
702704
return rc;
703705
}
704706

707+
int bnge_hwrm_vnic_set_hds(struct bnge_net *bn, struct bnge_vnic_info *vnic)
708+
{
709+
u16 hds_thresh = (u16)bn->netdev->cfg_pending->hds_thresh;
710+
struct hwrm_vnic_plcmodes_cfg_input *req;
711+
struct bnge_dev *bd = bn->bd;
712+
int rc;
713+
714+
rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_PLCMODES_CFG);
715+
if (rc)
716+
return rc;
717+
718+
req->flags = cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_JUMBO_PLACEMENT);
719+
req->enables = cpu_to_le32(BNGE_PLC_EN_JUMBO_THRES_VALID);
720+
req->jumbo_thresh = cpu_to_le16(bn->rx_buf_use_size);
721+
722+
if (bnge_is_agg_reqd(bd)) {
723+
req->flags |= cpu_to_le32(VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV4 |
724+
VNIC_PLCMODES_CFG_REQ_FLAGS_HDS_IPV6);
725+
req->enables |=
726+
cpu_to_le32(BNGE_PLC_EN_HDS_THRES_VALID);
727+
req->hds_threshold = cpu_to_le16(hds_thresh);
728+
}
729+
req->vnic_id = cpu_to_le32(vnic->fw_vnic_id);
730+
return bnge_hwrm_req_send(bd, req);
731+
}
732+
733+
int bnge_hwrm_vnic_ctx_alloc(struct bnge_dev *bd,
734+
struct bnge_vnic_info *vnic, u16 ctx_idx)
735+
{
736+
struct hwrm_vnic_rss_cos_lb_ctx_alloc_output *resp;
737+
struct hwrm_vnic_rss_cos_lb_ctx_alloc_input *req;
738+
int rc;
739+
740+
rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_COS_LB_CTX_ALLOC);
741+
if (rc)
742+
return rc;
743+
744+
resp = bnge_hwrm_req_hold(bd, req);
745+
rc = bnge_hwrm_req_send(bd, req);
746+
if (!rc)
747+
vnic->fw_rss_cos_lb_ctx[ctx_idx] =
748+
le16_to_cpu(resp->rss_cos_lb_ctx_id);
749+
bnge_hwrm_req_drop(bd, req);
750+
751+
return rc;
752+
}
753+
754+
static void
755+
__bnge_hwrm_vnic_set_rss(struct bnge_net *bn,
756+
struct hwrm_vnic_rss_cfg_input *req,
757+
struct bnge_vnic_info *vnic)
758+
{
759+
struct bnge_dev *bd = bn->bd;
760+
761+
bnge_fill_hw_rss_tbl(bn, vnic);
762+
req->flags |= VNIC_RSS_CFG_REQ_FLAGS_IPSEC_HASH_TYPE_CFG_SUPPORT;
763+
764+
req->hash_type = cpu_to_le32(bd->rss_hash_cfg);
765+
req->hash_mode_flags = VNIC_RSS_CFG_REQ_HASH_MODE_FLAGS_DEFAULT;
766+
req->ring_grp_tbl_addr = cpu_to_le64(vnic->rss_table_dma_addr);
767+
req->hash_key_tbl_addr = cpu_to_le64(vnic->rss_hash_key_dma_addr);
768+
}
769+
770+
int bnge_hwrm_vnic_set_rss(struct bnge_net *bn,
771+
struct bnge_vnic_info *vnic, bool set_rss)
772+
{
773+
struct hwrm_vnic_rss_cfg_input *req;
774+
struct bnge_dev *bd = bn->bd;
775+
dma_addr_t ring_tbl_map;
776+
u32 i, nr_ctxs;
777+
int rc;
778+
779+
rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_CFG);
780+
if (rc)
781+
return rc;
782+
783+
req->vnic_id = cpu_to_le16(vnic->fw_vnic_id);
784+
if (!set_rss)
785+
return bnge_hwrm_req_send(bd, req);
786+
787+
__bnge_hwrm_vnic_set_rss(bn, req, vnic);
788+
ring_tbl_map = vnic->rss_table_dma_addr;
789+
nr_ctxs = bnge_cal_nr_rss_ctxs(bd->rx_nr_rings);
790+
791+
bnge_hwrm_req_hold(bd, req);
792+
for (i = 0; i < nr_ctxs; ring_tbl_map += BNGE_RSS_TABLE_SIZE, i++) {
793+
req->ring_grp_tbl_addr = cpu_to_le64(ring_tbl_map);
794+
req->ring_table_pair_index = i;
795+
req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[i]);
796+
rc = bnge_hwrm_req_send(bd, req);
797+
if (rc)
798+
goto exit;
799+
}
800+
801+
exit:
802+
bnge_hwrm_req_drop(bd, req);
803+
return rc;
804+
}
805+
806+
int bnge_hwrm_vnic_cfg(struct bnge_net *bn, struct bnge_vnic_info *vnic)
807+
{
808+
struct bnge_rx_ring_info *rxr = &bn->rx_ring[0];
809+
struct hwrm_vnic_cfg_input *req;
810+
struct bnge_dev *bd = bn->bd;
811+
int rc;
812+
813+
rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_CFG);
814+
if (rc)
815+
return rc;
816+
817+
req->default_rx_ring_id =
818+
cpu_to_le16(rxr->rx_ring_struct.fw_ring_id);
819+
req->default_cmpl_ring_id =
820+
cpu_to_le16(bnge_cp_ring_for_rx(rxr));
821+
req->enables =
822+
cpu_to_le32(VNIC_CFG_REQ_ENABLES_DEFAULT_RX_RING_ID |
823+
VNIC_CFG_REQ_ENABLES_DEFAULT_CMPL_RING_ID);
824+
vnic->mru = bd->netdev->mtu + ETH_HLEN + VLAN_HLEN;
825+
req->mru = cpu_to_le16(vnic->mru);
826+
827+
req->vnic_id = cpu_to_le16(vnic->fw_vnic_id);
828+
829+
if (bd->flags & BNGE_EN_STRIP_VLAN)
830+
req->flags |= cpu_to_le32(VNIC_CFG_REQ_FLAGS_VLAN_STRIP_MODE);
831+
if (vnic->vnic_id == BNGE_VNIC_DEFAULT && bnge_aux_registered(bd))
832+
req->flags |= cpu_to_le32(BNGE_VNIC_CFG_ROCE_DUAL_MODE);
833+
834+
return bnge_hwrm_req_send(bd, req);
835+
}
836+
837+
void bnge_hwrm_update_rss_hash_cfg(struct bnge_net *bn)
838+
{
839+
struct bnge_vnic_info *vnic = &bn->vnic_info[BNGE_VNIC_DEFAULT];
840+
struct hwrm_vnic_rss_qcfg_output *resp;
841+
struct hwrm_vnic_rss_qcfg_input *req;
842+
struct bnge_dev *bd = bn->bd;
843+
844+
if (bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_QCFG))
845+
return;
846+
847+
req->vnic_id = cpu_to_le16(vnic->fw_vnic_id);
848+
/* all contexts configured to same hash_type, zero always exists */
849+
req->rss_ctx_idx = cpu_to_le16(vnic->fw_rss_cos_lb_ctx[0]);
850+
resp = bnge_hwrm_req_hold(bd, req);
851+
if (!bnge_hwrm_req_send(bd, req))
852+
bd->rss_hash_cfg =
853+
le32_to_cpu(resp->hash_type) ?: bd->rss_hash_cfg;
854+
bnge_hwrm_req_drop(bd, req);
855+
}
856+
857+
int bnge_hwrm_vnic_alloc(struct bnge_dev *bd, struct bnge_vnic_info *vnic,
858+
unsigned int nr_rings)
859+
{
860+
struct hwrm_vnic_alloc_output *resp;
861+
struct hwrm_vnic_alloc_input *req;
862+
unsigned int i;
863+
int rc;
864+
865+
rc = bnge_hwrm_req_init(bd, req, HWRM_VNIC_ALLOC);
866+
if (rc)
867+
return rc;
868+
869+
for (i = 0; i < BNGE_MAX_CTX_PER_VNIC; i++)
870+
vnic->fw_rss_cos_lb_ctx[i] = INVALID_HW_RING_ID;
871+
if (vnic->vnic_id == BNGE_VNIC_DEFAULT)
872+
req->flags = cpu_to_le32(VNIC_ALLOC_REQ_FLAGS_DEFAULT);
873+
874+
resp = bnge_hwrm_req_hold(bd, req);
875+
rc = bnge_hwrm_req_send(bd, req);
876+
if (!rc)
877+
vnic->fw_vnic_id = le32_to_cpu(resp->vnic_id);
878+
bnge_hwrm_req_drop(bd, req);
879+
return rc;
880+
}
881+
882+
void bnge_hwrm_vnic_free_one(struct bnge_dev *bd, struct bnge_vnic_info *vnic)
883+
{
884+
if (vnic->fw_vnic_id != INVALID_HW_RING_ID) {
885+
struct hwrm_vnic_free_input *req;
886+
887+
if (bnge_hwrm_req_init(bd, req, HWRM_VNIC_FREE))
888+
return;
889+
890+
req->vnic_id = cpu_to_le32(vnic->fw_vnic_id);
891+
892+
bnge_hwrm_req_send(bd, req);
893+
vnic->fw_vnic_id = INVALID_HW_RING_ID;
894+
}
895+
}
896+
897+
void bnge_hwrm_vnic_ctx_free_one(struct bnge_dev *bd,
898+
struct bnge_vnic_info *vnic, u16 ctx_idx)
899+
{
900+
struct hwrm_vnic_rss_cos_lb_ctx_free_input *req;
901+
902+
if (bnge_hwrm_req_init(bd, req, HWRM_VNIC_RSS_COS_LB_CTX_FREE))
903+
return;
904+
905+
req->rss_cos_lb_ctx_id =
906+
cpu_to_le16(vnic->fw_rss_cos_lb_ctx[ctx_idx]);
907+
908+
bnge_hwrm_req_send(bd, req);
909+
vnic->fw_rss_cos_lb_ctx[ctx_idx] = INVALID_HW_RING_ID;
910+
}
911+
705912
void bnge_hwrm_stat_ctx_free(struct bnge_net *bn)
706913
{
707914
struct hwrm_stat_ctx_free_input *req;

drivers/net/ethernet/broadcom/bnge/bnge_hwrm_lib.h

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,13 @@
44
#ifndef _BNGE_HWRM_LIB_H_
55
#define _BNGE_HWRM_LIB_H_
66

7+
#define BNGE_PLC_EN_JUMBO_THRES_VALID \
8+
VNIC_PLCMODES_CFG_REQ_ENABLES_JUMBO_THRESH_VALID
9+
#define BNGE_PLC_EN_HDS_THRES_VALID \
10+
VNIC_PLCMODES_CFG_REQ_ENABLES_HDS_THRESHOLD_VALID
11+
#define BNGE_VNIC_CFG_ROCE_DUAL_MODE \
12+
VNIC_CFG_REQ_FLAGS_ROCE_DUAL_VNIC_MODE
13+
714
int bnge_hwrm_ver_get(struct bnge_dev *bd);
815
int bnge_hwrm_func_reset(struct bnge_dev *bd);
916
int bnge_hwrm_fw_set_time(struct bnge_dev *bd);
@@ -24,6 +31,18 @@ int bnge_hwrm_func_qcfg(struct bnge_dev *bd);
2431
int bnge_hwrm_func_resc_qcaps(struct bnge_dev *bd);
2532
int bnge_hwrm_queue_qportcfg(struct bnge_dev *bd);
2633

34+
int bnge_hwrm_vnic_set_hds(struct bnge_net *bn, struct bnge_vnic_info *vnic);
35+
int bnge_hwrm_vnic_ctx_alloc(struct bnge_dev *bd,
36+
struct bnge_vnic_info *vnic, u16 ctx_idx);
37+
int bnge_hwrm_vnic_set_rss(struct bnge_net *bn,
38+
struct bnge_vnic_info *vnic, bool set_rss);
39+
int bnge_hwrm_vnic_cfg(struct bnge_net *bn, struct bnge_vnic_info *vnic);
40+
void bnge_hwrm_update_rss_hash_cfg(struct bnge_net *bn);
41+
int bnge_hwrm_vnic_alloc(struct bnge_dev *bd, struct bnge_vnic_info *vnic,
42+
unsigned int nr_rings);
43+
void bnge_hwrm_vnic_free_one(struct bnge_dev *bd, struct bnge_vnic_info *vnic);
44+
void bnge_hwrm_vnic_ctx_free_one(struct bnge_dev *bd,
45+
struct bnge_vnic_info *vnic, u16 ctx_idx);
2746
void bnge_hwrm_stat_ctx_free(struct bnge_net *bn);
2847
int bnge_hwrm_stat_ctx_alloc(struct bnge_net *bn);
2948
int hwrm_ring_free_send_msg(struct bnge_net *bn, struct bnge_ring_struct *ring,

0 commit comments

Comments
 (0)