[dpdk-dev] [PATCH v2 2/2] drivers/net/vmxnet3: add ethdev functions

Stephen Hemminger stephen at networkplumber.org
Fri Mar 4 21:34:52 CET 2016


On Fri,  4 Mar 2016 15:25:24 +0000
Remy Horton <remy.horton at intel.com> wrote:

> Implements driver support for setting of MAC address.
> 
> Signed-off-by: Remy Horton <remy.horton at intel.com>
> ---
>  doc/guides/rel_notes/release_16_04.rst |  4 ++++
>  drivers/net/vmxnet3/vmxnet3_ethdev.c   | 19 +++++++++++++++++++
>  2 files changed, 23 insertions(+)
> 
> diff --git a/doc/guides/rel_notes/release_16_04.rst b/doc/guides/rel_notes/release_16_04.rst
> index 4e0112e..39db674 100644
> --- a/doc/guides/rel_notes/release_16_04.rst
> +++ b/doc/guides/rel_notes/release_16_04.rst
> @@ -62,6 +62,10 @@ This section should contain new features added in this release. Sample format:
>    Implemented driver functions for Register dumping, EEPROM dumping, and
>    setting of MAC address.
>  
> +* **vmxnet3: Added ethdev support functions.**
> +
> +  Implemented driver functionality for setting MAC address.
> +
>  
>  Resolved Issues
>  ---------------
> diff --git a/drivers/net/vmxnet3/vmxnet3_ethdev.c b/drivers/net/vmxnet3/vmxnet3_ethdev.c
> index c363bf6..bc83524 100644
> --- a/drivers/net/vmxnet3/vmxnet3_ethdev.c
> +++ b/drivers/net/vmxnet3/vmxnet3_ethdev.c
> @@ -91,6 +91,8 @@ static int vmxnet3_dev_vlan_filter_set(struct rte_eth_dev *dev,
>  static void vmxnet3_dev_vlan_offload_set(struct rte_eth_dev *dev, int mask);
>  static void vmxnet3_dev_vlan_offload_set_clear(struct rte_eth_dev *dev,
>  						int mask, int clear);
> +static void vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
> +				 struct ether_addr *mac_addr);
>  
>  #if PROCESS_SYS_EVENTS == 1
>  static void vmxnet3_process_events(struct vmxnet3_hw *);
> @@ -124,6 +126,7 @@ static const struct eth_dev_ops vmxnet3_eth_dev_ops = {
>  	.rx_queue_release     = vmxnet3_dev_rx_queue_release,
>  	.tx_queue_setup       = vmxnet3_dev_tx_queue_setup,
>  	.tx_queue_release     = vmxnet3_dev_tx_queue_release,
> +	.mac_addr_set         = vmxnet3_mac_addr_set,
>  };
>  
>  static const struct rte_memzone *
> @@ -922,6 +925,22 @@ vmxnet3_process_events(struct vmxnet3_hw *hw)
>  }
>  #endif
>  
> +static void vmxnet3_mac_addr_set(struct rte_eth_dev *dev,
> +				 struct ether_addr *mac_addr)
> +{
> +	struct vmxnet3_hw *hw = dev->data->dev_private;
> +	uint32_t mac_hi, mac_lo;
> +
> +	if (!is_valid_assigned_ether_addr(mac_addr)) {
> +		PMD_DRV_LOG(ERR, "Tried to set invalid MAC address.");
> +		return;
> +	}
> +	memcpy(&mac_lo, mac_addr, 4);
> +	memcpy(&mac_hi, mac_addr + 4, 2);
> +	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACL, mac_lo);
> +	VMXNET3_WRITE_BAR1_REG(hw, VMXNET3_REG_MACH, mac_hi);
> +}
> +
>  static struct rte_driver rte_vmxnet3_driver = {
>  	.type = PMD_PDEV,
>  	.init = rte_vmxnet3_pmd_init,

The version I posted is simpler and reuses existing code paths.


More information about the dev mailing list