Skip to content

Commit

Permalink
ethdev: add default mac address modifier
Browse files Browse the repository at this point in the history
Add new api:
- rte_eth_dev_default_mac_addr_set

The new api, rte_eth_dev_default_mac_addr_set, uses the
existing dev_op, mac_addr_set, to enable setting mac
addr from ethdev level.

Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
Acked-by: Andrew Harvey <agh@cisco.com>
Acked-by: David Harton <dharton@cisco.com>
Acked-by: Konstantin Ananyev <konstantin.ananyev@intel.com>
  • Loading branch information
wangliangmin1962 authored and Thomas Monjalon committed Jul 16, 2015
1 parent 1ca4d34 commit 854d8ad
Show file tree
Hide file tree
Showing 3 changed files with 38 additions and 0 deletions.
21 changes: 21 additions & 0 deletions lib/librte_ether/rte_ethdev.c
Original file line number Diff line number Diff line change
Expand Up @@ -2541,6 +2541,27 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr)
return 0;
}

int
rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr)
{
struct rte_eth_dev *dev;

VALID_PORTID_OR_ERR_RET(port_id, -ENODEV);

if (!is_valid_assigned_ether_addr(addr))
return -EINVAL;

dev = &rte_eth_devices[port_id];
FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP);

/* Update default address in NIC data structure */
ether_addr_copy(addr, &dev->data->mac_addrs[0]);

(*dev->dev_ops->mac_addr_set)(dev, addr);

return 0;
}

int
rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf,
uint16_t rx_mode, uint8_t on)
Expand Down
16 changes: 16 additions & 0 deletions lib/librte_ether/rte_ethdev.h
Original file line number Diff line number Diff line change
Expand Up @@ -3020,6 +3020,22 @@ int rte_eth_dev_mac_addr_add(uint8_t port, struct ether_addr *mac_addr,
*/
int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr);

/**
* Set the default MAC address.
*
* @param port
* The port identifier of the Ethernet device.
* @param mac_addr
* New default MAC address.
* @return
* - (0) if successful, or *mac_addr* didn't exist.
* - (-ENOTSUP) if hardware doesn't support.
* - (-ENODEV) if *port* invalid.
* - (-EINVAL) if MAC address is invalid.
*/
int rte_eth_dev_default_mac_addr_set(uint8_t port, struct ether_addr *mac_addr);


/**
* Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device.
*
Expand Down
1 change: 1 addition & 0 deletions lib/librte_ether/rte_ether_version.map
Original file line number Diff line number Diff line change
Expand Up @@ -109,6 +109,7 @@ DPDK_2.0 {
DPDK_2.1 {
global:

rte_eth_dev_default_mac_addr_set;
rte_eth_dev_set_mc_addr_list;
rte_eth_timesync_disable;
rte_eth_timesync_enable;
Expand Down

0 comments on commit 854d8ad

Please sign in to comment.