From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from rnd-relay.smtp.broadcom.com (lpdvrndsmtp01.broadcom.com [192.19.229.170]) by dpdk.org (Postfix) with ESMTP id 8FF0D7CCD for ; Thu, 1 Jun 2017 05:02:45 +0200 (CEST) Received: from mail-irv-17.broadcom.com (mail-irv-17.lvn.broadcom.net [10.75.224.233]) by rnd-relay.smtp.broadcom.com (Postfix) with ESMTP id 9F59130C048; Wed, 31 May 2017 20:02:44 -0700 (PDT) DKIM-Filter: OpenDKIM Filter v2.10.3 rnd-relay.smtp.broadcom.com 9F59130C048 DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/simple; d=broadcom.com; s=dkimrelay; t=1496286164; bh=0ktBlZsRjCgvBZlzUvzSvl9ED3KJrzpKJYt8IdR+9PQ=; h=From:To:Cc:Subject:Date:In-Reply-To:References:From; b=rIBXUsrem2SRjkBPwxqKktvheay7I2wDqFzfNlCu5wUyMSCSCws8W2A33bgBSGAHF 6K1YN6cByKDUBmhQLgi6Dz8TJJin8tmgu4T0kN3pnkvDFrDfRe9n8A/lovjLzMPbk3 8Z63QAwv+ewDzqgHB95LvZWQF5ZkkryBDBdATGV4= Received: from C02PT1RBG8WP.vpn.broadcom.net (unknown [10.10.118.254]) by mail-irv-17.broadcom.com (Postfix) with ESMTP id BBB4082060; Wed, 31 May 2017 20:02:43 -0700 (PDT) From: Ajit Khaparde To: dev@dpdk.org Cc: ferruh.yigit@intel.com Date: Wed, 31 May 2017 22:02:15 -0500 Message-Id: <20170601030232.38677-10-ajit.khaparde@broadcom.com> X-Mailer: git-send-email 2.10.1 (Apple Git-78) In-Reply-To: <20170601030232.38677-1-ajit.khaparde@broadcom.com> References: <5d0e287f-dfe9-3a41-695e-9af0d57d37c1@intel.com> <20170601030232.38677-1-ajit.khaparde@broadcom.com> Subject: [dpdk-dev] [PATCH v3 09/26] net/bnxt: add support for set multicast addr list and MAC addr set X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Thu, 01 Jun 2017 03:02:46 -0000 This patch adds support for set_mc_addr_list and mac_addr_set dev_ops Signed-off-by: Ajit Khaparde -- v1->v2: regroup related patches and incorporate other review comments v2->v3: - rebasing to next-net tree - Use net/bnxt instead of just bnxt in patch subject - Split the patch to document "Allmulticast mode" in bnxt.ini --- drivers/net/bnxt/bnxt_ethdev.c | 74 ++++++++++++++++++++++++++++++++++++++++-- drivers/net/bnxt/bnxt_hwrm.c | 13 +++++--- drivers/net/bnxt/bnxt_hwrm.h | 2 +- drivers/net/bnxt/bnxt_vnic.c | 7 +++- drivers/net/bnxt/bnxt_vnic.h | 4 +++ 5 files changed, 91 insertions(+), 9 deletions(-) diff --git a/drivers/net/bnxt/bnxt_ethdev.c b/drivers/net/bnxt/bnxt_ethdev.c index 5073cd8..ef14fb9 100644 --- a/drivers/net/bnxt/bnxt_ethdev.c +++ b/drivers/net/bnxt/bnxt_ethdev.c @@ -638,7 +638,7 @@ static int bnxt_mac_addr_add_op(struct rte_eth_dev *eth_dev, STAILQ_INSERT_TAIL(&vnic->filter, filter, next); filter->mac_index = index; memcpy(filter->l2_addr, mac_addr, ETHER_ADDR_LEN); - return bnxt_hwrm_set_filter(bp, vnic, filter); + return bnxt_hwrm_set_filter(bp, vnic->fw_vnic_id, filter); } int bnxt_link_update_op(struct rte_eth_dev *eth_dev, int wait_to_complete) @@ -1155,7 +1155,7 @@ static int bnxt_del_vlan_filter(struct bnxt *bp, uint16_t vlan_id) filter->l2_addr, ETHER_ADDR_LEN); /* MAC only filter */ rc = bnxt_hwrm_set_filter(bp, - vnic, + vnic->fw_vnic_id, new_filter); if (rc) goto exit; @@ -1229,7 +1229,7 @@ static int bnxt_add_vlan_filter(struct bnxt *bp, uint16_t vlan_id) new_filter->l2_ovlan = vlan_id; new_filter->l2_ovlan_mask = 0xF000; new_filter->enables |= en; - rc = bnxt_hwrm_set_filter(bp, vnic, + rc = bnxt_hwrm_set_filter(bp, vnic->fw_vnic_id, new_filter); if (rc) goto exit; @@ -1290,6 +1290,72 @@ bnxt_vlan_offload_set_op(struct rte_eth_dev *dev, int mask) RTE_LOG(ERR, PMD, "Extend VLAN Not supported\n"); } +static void +bnxt_set_default_mac_addr_op(struct rte_eth_dev *dev, struct ether_addr *addr) +{ + struct bnxt *bp = (struct bnxt *)dev->data->dev_private; + /* Default Filter is tied to VNIC 0 */ + struct bnxt_vnic_info *vnic = &bp->vnic_info[0]; + struct bnxt_filter_info *filter; + int rc; + + if (BNXT_VF(bp)) + return; + + memcpy(bp->mac_addr, addr, sizeof(bp->mac_addr)); + memcpy(&dev->data->mac_addrs[0], bp->mac_addr, ETHER_ADDR_LEN); + + STAILQ_FOREACH(filter, &vnic->filter, next) { + /* Default Filter is at Index 0 */ + if (filter->mac_index != 0) + continue; + rc = bnxt_hwrm_clear_filter(bp, filter); + if (rc) + break; + memcpy(filter->l2_addr, bp->mac_addr, ETHER_ADDR_LEN); + memset(filter->l2_addr_mask, 0xff, ETHER_ADDR_LEN); + filter->flags |= HWRM_CFA_L2_FILTER_ALLOC_INPUT_FLAGS_PATH_RX; + filter->enables |= + HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR | + HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR_MASK; + rc = bnxt_hwrm_set_filter(bp, vnic->fw_vnic_id, filter); + if (rc) + break; + filter->mac_index = 0; + RTE_LOG(DEBUG, PMD, "Set MAC addr\n"); + } +} + +static int +bnxt_dev_set_mc_addr_list_op(struct rte_eth_dev *eth_dev, + struct ether_addr *mc_addr_set, + uint32_t nb_mc_addr) +{ + struct bnxt *bp = (struct bnxt *)eth_dev->data->dev_private; + char *mc_addr_list = (char *)mc_addr_set; + struct bnxt_vnic_info *vnic; + uint32_t off = 0, i = 0; + + vnic = &bp->vnic_info[0]; + + if (nb_mc_addr > BNXT_MAX_MC_ADDRS) { + vnic->flags |= BNXT_VNIC_INFO_ALLMULTI; + goto allmulti; + } + + /* TODO Check for Duplicate mcast addresses */ + vnic->flags &= ~BNXT_VNIC_INFO_ALLMULTI; + for (i = 0; i < nb_mc_addr; i++) { + memcpy(vnic->mc_list + off, &mc_addr_list[i], ETHER_ADDR_LEN); + off += ETHER_ADDR_LEN; + } + + vnic->mc_addr_cnt = i; + +allmulti: + return bnxt_hwrm_cfa_l2_set_rx_mask(bp, vnic); +} + /* * Initialization */ @@ -1325,9 +1391,11 @@ static const struct eth_dev_ops bnxt_dev_ops = { .udp_tunnel_port_del = bnxt_udp_tunnel_port_del_op, .vlan_filter_set = bnxt_vlan_filter_set_op, .vlan_offload_set = bnxt_vlan_offload_set_op, + .mac_addr_set = bnxt_set_default_mac_addr_op, .xstats_get = bnxt_dev_xstats_get_op, .xstats_get_names = bnxt_dev_xstats_get_names_op, .xstats_reset = bnxt_dev_xstats_reset_op, + .set_mc_addr_list = bnxt_dev_set_mc_addr_list_op, }; static bool bnxt_vf_pciid(uint16_t id) diff --git a/drivers/net/bnxt/bnxt_hwrm.c b/drivers/net/bnxt/bnxt_hwrm.c index d942648..22e18d6 100644 --- a/drivers/net/bnxt/bnxt_hwrm.c +++ b/drivers/net/bnxt/bnxt_hwrm.c @@ -229,7 +229,12 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic) if (vnic->flags & BNXT_VNIC_INFO_PROMISC) mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_PROMISCUOUS; if (vnic->flags & BNXT_VNIC_INFO_ALLMULTI) - mask = HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST; + mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_ALL_MCAST; + if (vnic->mc_addr_cnt) { + mask |= HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_MCAST; + req.num_mc_entries = rte_cpu_to_le_32(vnic->mc_addr_cnt); + req.mc_tbl_addr = rte_cpu_to_le_64(vnic->mc_list_dma_addr); + } req.mask = rte_cpu_to_le_32(HWRM_CFA_L2_SET_RX_MASK_INPUT_MASK_BCAST | mask); @@ -261,7 +266,7 @@ int bnxt_hwrm_clear_filter(struct bnxt *bp, } int bnxt_hwrm_set_filter(struct bnxt *bp, - struct bnxt_vnic_info *vnic, + uint16_t dst_id, struct bnxt_filter_info *filter) { int rc = 0; @@ -275,7 +280,7 @@ int bnxt_hwrm_set_filter(struct bnxt *bp, enables = filter->enables | HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_DST_ID; - req.dst_id = rte_cpu_to_le_16(vnic->fw_vnic_id); + req.dst_id = rte_cpu_to_le_16(dst_id); if (enables & HWRM_CFA_L2_FILTER_ALLOC_INPUT_ENABLES_L2_ADDR) @@ -1419,7 +1424,7 @@ int bnxt_set_hwrm_vnic_filters(struct bnxt *bp, struct bnxt_vnic_info *vnic) int rc = 0; STAILQ_FOREACH(filter, &vnic->filter, next) { - rc = bnxt_hwrm_set_filter(bp, vnic, filter); + rc = bnxt_hwrm_set_filter(bp, vnic->fw_vnic_id, filter); if (rc) break; } diff --git a/drivers/net/bnxt/bnxt_hwrm.h b/drivers/net/bnxt/bnxt_hwrm.h index 8f7d103..c15404f 100644 --- a/drivers/net/bnxt/bnxt_hwrm.h +++ b/drivers/net/bnxt/bnxt_hwrm.h @@ -49,7 +49,7 @@ int bnxt_hwrm_cfa_l2_set_rx_mask(struct bnxt *bp, struct bnxt_vnic_info *vnic); int bnxt_hwrm_clear_filter(struct bnxt *bp, struct bnxt_filter_info *filter); int bnxt_hwrm_set_filter(struct bnxt *bp, - struct bnxt_vnic_info *vnic, + uint16_t dst_id, struct bnxt_filter_info *filter); int bnxt_hwrm_exec_fwd_resp(struct bnxt *bp, uint16_t target_id, void *encaped, size_t ec_size); diff --git a/drivers/net/bnxt/bnxt_vnic.c b/drivers/net/bnxt/bnxt_vnic.c index fe2244b..db9fb07 100644 --- a/drivers/net/bnxt/bnxt_vnic.c +++ b/drivers/net/bnxt/bnxt_vnic.c @@ -170,7 +170,8 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) char mz_name[RTE_MEMZONE_NAMESIZE]; uint32_t entry_length = RTE_CACHE_LINE_ROUNDUP( HW_HASH_INDEX_SIZE * sizeof(*vnic->rss_table) + - HW_HASH_KEY_SIZE); + HW_HASH_KEY_SIZE + + BNXT_MAX_MC_ADDRS * ETHER_ADDR_LEN); uint16_t max_vnics; int i; phys_addr_t mz_phys_addr; @@ -218,6 +219,10 @@ int bnxt_alloc_vnic_attributes(struct bnxt *bp) vnic->rss_hash_key_dma_addr = vnic->rss_table_dma_addr + HW_HASH_INDEX_SIZE * sizeof(*vnic->rss_table); + vnic->mc_list = (void *)((char *)vnic->rss_hash_key + + HW_HASH_KEY_SIZE); + vnic->mc_list_dma_addr = vnic->rss_hash_key_dma_addr + + HW_HASH_KEY_SIZE; } return 0; diff --git a/drivers/net/bnxt/bnxt_vnic.h b/drivers/net/bnxt/bnxt_vnic.h index ca1c9cf..0d50224 100644 --- a/drivers/net/bnxt/bnxt_vnic.h +++ b/drivers/net/bnxt/bnxt_vnic.h @@ -57,6 +57,10 @@ struct bnxt_vnic_info { uint16_t *rss_table; phys_addr_t rss_hash_key_dma_addr; void *rss_hash_key; + phys_addr_t mc_list_dma_addr; + char *mc_list; + uint32_t mc_addr_cnt; +#define BNXT_MAX_MC_ADDRS 16 uint32_t flags; #define BNXT_VNIC_INFO_PROMISC (1 << 0) #define BNXT_VNIC_INFO_ALLMULTI (1 << 1) -- 2.10.1 (Apple Git-78)