All of lore.kernel.org
 help / color / mirror / Atom feed
From: "Qiu, Michael" <michael.qiu@intel.com>
To: "He, Shaopeng" <shaopeng.he@intel.com>, "dev@dpdk.org" <dev@dpdk.org>
Subject: Re: [PATCH v2 2/3] fm10k: add MAC filter
Date: Tue, 16 Jun 2015 12:38:39 +0000	[thread overview]
Message-ID: <533710CFB86FA344BFBF2D6802E602860469C505@SHSMSX101.ccr.corp.intel.com> (raw)
In-Reply-To: 1434331439-31223-3-git-send-email-shaopeng.he@intel.com

On 6/15/2015 9:25 AM, 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@intel.com>

[.../...]

> @@ -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;
> @@ -863,11 +865,17 @@ 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");

It's  so strange why so many indentations here.

> +			break;
> +		}
>  		fm10k_mbx_lock(hw);
>  		result = fm10k_update_uc_addr(hw, hw->mac.dglort_map,
>  			data->mac_addrs[mac_index].addr_bytes,
>  			vlan_id, on, 0);
>  		fm10k_mbx_unlock(hw);
> +		mac_num++;
>  	}
>  	if (result != FM10K_SUCCESS) {
>  		PMD_INIT_LOG(ERR, "MAC address update failed: %d", result);
> @@ -884,6 +892,72 @@ fm10k_vlan_filter_set(struct rte_eth_dev *dev, uint16_t vlan_id, int on)
>  	return 0;
>  }
>  
> +/* 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) {
> +		PMD_INIT_LOG(ERR, "MAC filter not available on VF");
> +		return;
> +	}
> +
> +	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");
> +						return;
> +					}
> +					fm10k_mbx_lock(hw);
> +					fm10k_update_uc_addr(hw,
> +						hw->mac.dglort_map, mac,
> +						j * FM10K_UINT32_BIT_SIZE + k,
> +						add, 0);
> +					fm10k_mbx_unlock(hw);
> +					i++;
> +				}
> +			}
> +		}
> +	}
> +
> +	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)
>  {
> @@ -1736,6 +1810,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,
> @@ -1817,7 +1893,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;


  reply	other threads:[~2015-06-16 12:38 UTC|newest]

Thread overview: 27+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2015-06-02  2:58 [PATCH 0/3] fm10k: update MAC/VLAN filter and VLAN offload features Shaopeng He
2015-06-02  2:58 ` [PATCH 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-09  2:54   ` Chen, Jing D
2015-06-09  7:18     ` He, Shaopeng
2015-06-09 15:51   ` Qiu, Michael
2015-06-10  5:52     ` He, Shaopeng
2015-06-02  2:58 ` [PATCH 2/3] fm10k: add MAC filter Shaopeng He
2015-06-09  3:25   ` Chen, Jing D
2015-06-09  8:31     ` He, Shaopeng
2015-06-09 15:59   ` Qiu, Michael
2015-06-10  1:03     ` He, Shaopeng
2015-06-02  2:58 ` [PATCH 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-09  3:27   ` Chen, Jing D
2015-06-09  8:55     ` He, Shaopeng
2015-06-09 15:40     ` Qiu, Michael
2015-06-10  6:03       ` He, Shaopeng
2015-06-15  1:23 ` [PATCH v2 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-15  1:23   ` [PATCH v2 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-15  1:23   ` [PATCH v2 2/3] fm10k: add MAC filter Shaopeng He
2015-06-16 12:38     ` Qiu, Michael [this message]
2015-06-15  1:23   ` [PATCH v2 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18  7:21   ` [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Shaopeng He
2015-06-18  7:21     ` [PATCH v3 1/3] fm10k: update VLAN filter Shaopeng He
2015-06-18  7:21     ` [PATCH v3 2/3] fm10k: add MAC filter Shaopeng He
2015-06-18  7:21     ` [PATCH v3 3/3] fm10k: update VLAN offload features Shaopeng He
2015-06-18  8:23     ` [PATCH v3 0/3] fm10k: update MAC/VLAN filter and " Chen, Jing D
2015-06-22 14:21       ` Thomas Monjalon

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=533710CFB86FA344BFBF2D6802E602860469C505@SHSMSX101.ccr.corp.intel.com \
    --to=michael.qiu@intel.com \
    --cc=dev@dpdk.org \
    --cc=shaopeng.he@intel.com \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.