> -----Original Message-----
> From: Chen, Jing D
> Sent: Tuesday, June 09, 2015 11:25 AM
> To: He, Shaopeng; dev at dpdk.org
> Cc: Qiu, Michael
> Subject: RE: [PATCH 2/3] fm10k: add MAC filter
>
> Hi,
>
> > -----Original Message-----
> > From: He, Shaopeng
> > Sent: Tuesday, June 02, 2015 10:59 AM
> > To: dev at dpdk.org
> > Cc: Chen, Jing D; Qiu, Michael; He, Shaopeng
> > Subject: [PATCH 2/3] fm10k: add MAC filter
> >
> > MAC filter function was newly added, each PF and VF can have up to 64
> > MAC addresses. VF filter needs support from PF host, which is not available
> now.
> >
> > Signed-off-by: Shaopeng He <shaopeng.he at intel.com>
> > ---
> > drivers/net/fm10k/fm10k.h | 3 +-
> > drivers/net/fm10k/fm10k_ethdev.c | 90
> > ++++++++++++++++++++++++++++++++++++----
> > 2 files changed, 85 insertions(+), 8 deletions(-)
> >
> > diff --git a/drivers/net/fm10k/fm10k.h b/drivers/net/fm10k/fm10k.h
> > index 3b95b72..f5be5f8 100644
> > --- a/drivers/net/fm10k/fm10k.h
> > +++ b/drivers/net/fm10k/fm10k.h
> > @@ -110,7 +110,7 @@
> > #define FM10K_VLAN_TAG_SIZE 4
> >
> > /* Maximum number of MAC addresses per PF/VF */
> > -#define FM10K_MAX_MACADDR_NUM 1
> > +#define FM10K_MAX_MACADDR_NUM 64
> >
> > #define FM10K_UINT32_BIT_SIZE (CHAR_BIT * sizeof(uint32_t))
> > #define FM10K_VFTA_SIZE (4096 / FM10K_UINT32_BIT_SIZE)
> > @@ -125,6 +125,7 @@
> >
> > struct fm10k_macvlan_filter_info {
> > uint16_t vlan_num; /* Total VLAN number */
> > + uint16_t mac_num; /* Total mac number */
> > uint32_t vfta[FM10K_VFTA_SIZE]; /* VLAN bitmap */
> > };
> >
> > diff --git a/drivers/net/fm10k/fm10k_ethdev.c
> > b/drivers/net/fm10k/fm10k_ethdev.c
> > index d2f3e44..4f23bf1 100644
> > --- a/drivers/net/fm10k/fm10k_ethdev.c
> > +++ b/drivers/net/fm10k/fm10k_ethdev.c
> > @@ -54,6 +54,10 @@
> > #define BIT_MASK_PER_UINT32 ((1 << CHARS_PER_UINT32) - 1)
> >
> > static void fm10k_close_mbx_service(struct fm10k_hw *hw);
> > +static int
> > +fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int
> > +on); static void fm10k_MAC_filter_set(struct rte_eth_dev *dev, const
> > +u8 *mac, bool add);
> >
> > static void
> > fm10k_mbx_initlock(struct fm10k_hw *hw) @@ -668,14 +672,11 @@
> > fm10k_dev_start(struct rte_eth_dev *dev)
> > }
> >
> > if (hw->mac.default_vid && hw->mac.default_vid <=
> > ETHER_MAX_VLAN_ID) {
> > - fm10k_mbx_lock(hw);
> > /* Update default vlan */
> > - hw->mac.ops.update_vlan(hw, hw->mac.default_vid, 0,
> > true);
> > + fm10k_vlan_filter_set(dev, hw->mac.default_vid, true);
> >
> > /* Add default mac/vlan filter to PF/Switch manger */
> > - hw->mac.ops.update_uc_addr(hw, hw->mac.dglort_map,
> > hw->mac.addr,
> > - hw->mac.default_vid, true, 0);
> > - fm10k_mbx_unlock(hw);
> > + fm10k_MAC_filter_set(dev, hw->mac.addr, true);
> > }
> >
> > return 0;
> > @@ -781,7 +782,7 @@ fm10k_dev_infos_get(struct rte_eth_dev *dev,
> > dev_info->max_rx_pktlen = FM10K_MAX_PKT_SIZE;
> > dev_info->max_rx_queues = hw->mac.max_queues;
> > dev_info->max_tx_queues = hw->mac.max_queues;
> > - dev_info->max_mac_addrs = 1;
> > + dev_info->max_mac_addrs = FM10K_MAX_MACADDR_NUM;
> > dev_info->max_hash_mac_addrs = 0;
> > dev_info->max_vfs = FM10K_MAX_VF_NUM;
> > dev_info->max_vmdq_pools = ETH_64_POOLS;
> > @@ -820,6 +821,7 @@ static int
> > fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int
> > on) {
> > s32 result;
> > + uint16_t mac_num = 0;
> > uint32_t vid_idx, vid_bit, mac_index;
> > struct fm10k_hw *hw;
> > struct fm10k_macvlan_filter_info *macvlan; @@ -864,9 +866,15 @@
> > fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int
> > on)
> > mac_index++) {
> > if (is_zero_ether_addr(&data-
> > >mac_addrs[mac_index]))
> > continue;
> > + if (mac_num > macvlan->mac_num - 1) {
> > + PMD_INIT_LOG(ERR, "MAC address number
> > "
> > + "not match");
> > + break;
> > + }
> > fm10k_update_uc_addr(hw, hw->mac.dglort_map,
> > data->mac_addrs[mac_index].addr_bytes,
> > vlan_id, on, 0);
> > + mac_num++;
> > }
> > }
> > fm10k_mbx_unlock(hw);
> > @@ -876,6 +884,71 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev,
> > uint16_t vlan_id, int on)
> > return (-EIO);
> > }
> >
> > +/* Add/Remove a MAC address, and update filters */ static void
> > +fm10k_MAC_filter_set(struct rte_eth_dev *dev, const u8 *mac, bool
> > +add) {
> > + uint32_t i, j, k;
> > + struct fm10k_hw *hw;
> > + struct fm10k_macvlan_filter_info *macvlan;
> > +
> > + hw = FM10K_DEV_PRIVATE_TO_HW(dev->data->dev_private);
> > + macvlan = FM10K_DEV_PRIVATE_TO_MACVLAN(dev->data-
> > >dev_private);
> > +
> > + /* @todo - add support for the VF */
> > + if (hw->mac.type != fm10k_mac_pf)
> > + return;
> > +
>
> Since it only supports PF, it's better to clarify in the log.
Accept, thanks for the comment