[dpdk-dev] [PATCH 2/3] fm10k: add MAC filter

Qiu, Michael michael.qiu at intel.com
Tue Jun 9 17:59:31 CEST 2015


On 2015/6/2 10:59, He, Shaopeng wrote:
> 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(-)

...

> ;
> +
> +	fm10k_mbx_lock(hw);
> +	i = 0;
> +	for (j = 0; j < FM10K_VFTA_SIZE; j++) {
> +		if (macvlan->vfta[j]) {
> +			for (k = 0; k < FM10K_UINT32_BIT_SIZE; k++) {
> +				if (macvlan->vfta[j] & (1 << k)) {
> +					if (i + 1 > macvlan->vlan_num) {
> +						PMD_INIT_LOG(ERR, "vlan number "
> +								"not match");
> +						fm10k_mbx_unlock(hw);
> +						return;
> +					}
> +					fm10k_update_uc_addr(hw,
> +						hw->mac.dglort_map,	mac,

Here before 'mac', does it has a incident? if no, please ignore, maybe
my mail client's issue.

Thanks,
Michael
> +						j * FM10K_UINT32_BIT_SIZE + k,
> +						add, 0);
> +					i++;
> +				}
> +			}
> +		}
> +	}
> +	fm10k_mbx_unlock(hw);
> +
> +	if (add)
> +		macvlan->mac_num++;
> +	else
> +		macvlan->mac_num--;
> +}
> +
> +/* Add a MAC address, and update filters */
> +static void
> +fm10k_macaddr_add(struct rte_eth_dev *dev,
> +		 struct ether_addr *mac_addr,
> +		 __rte_unused uint32_t index,
> +		 __rte_unused uint32_t pool)
> +{
> +	fm10k_MAC_filter_set(dev, mac_addr->addr_bytes, TRUE);
> +}
> +
> +/* Remove a MAC address, and update filters */
> +static void
> +fm10k_macaddr_remove(struct rte_eth_dev *dev, uint32_t index)
> +{
> +	struct rte_eth_dev_data *data = dev->data;
> +
> +	if (index < FM10K_MAX_MACADDR_NUM)
> +		fm10k_MAC_filter_set(dev, data->mac_addrs[index].addr_bytes,
> +				FALSE);
> +}
> +
>  static inline int
>  check_nb_desc(uint16_t min, uint16_t max, uint16_t mult, uint16_t request)
>  {
> @@ -1728,6 +1801,8 @@ static const struct eth_dev_ops fm10k_eth_dev_ops = {
>  	.link_update		= fm10k_link_update,
>  	.dev_infos_get		= fm10k_dev_infos_get,
>  	.vlan_filter_set	= fm10k_vlan_filter_set,
> +	.mac_addr_add		= fm10k_macaddr_add,
> +	.mac_addr_remove	= fm10k_macaddr_remove,
>  	.rx_queue_start		= fm10k_dev_rx_queue_start,
>  	.rx_queue_stop		= fm10k_dev_rx_queue_stop,
>  	.tx_queue_start		= fm10k_dev_tx_queue_start,
> @@ -1809,7 +1884,8 @@ eth_fm10k_dev_init(struct rte_eth_dev *dev)
>  	}
>  
>  	/* Initialize MAC address(es) */
> -	dev->data->mac_addrs = rte_zmalloc("fm10k", ETHER_ADDR_LEN, 0);
> +	dev->data->mac_addrs = rte_zmalloc("fm10k",
> +			ETHER_ADDR_LEN * FM10K_MAX_MACADDR_NUM, 0);
>  	if (dev->data->mac_addrs == NULL) {
>  		PMD_INIT_LOG(ERR, "Cannot allocate memory for MAC addresses");
>  		return -ENOMEM;



More information about the dev mailing list