Message ID | 1432927612-12244-2-git-send-email-liang-min.wang@intel.com (mailing list archive) |
---|---|
State | Superseded, archived |
Headers |
Return-Path: <dev-bounces@dpdk.org> X-Original-To: patchwork@dpdk.org Delivered-To: patchwork@dpdk.org Received: from [92.243.14.124] (localhost [IPv6:::1]) by dpdk.org (Postfix) with ESMTP id B80A0B38D; Fri, 29 May 2015 21:27:01 +0200 (CEST) Received: from mga01.intel.com (mga01.intel.com [192.55.52.88]) by dpdk.org (Postfix) with ESMTP id 307C4FFA for <dev@dpdk.org>; Fri, 29 May 2015 21:26:59 +0200 (CEST) Received: from orsmga001.jf.intel.com ([10.7.209.18]) by fmsmga101.fm.intel.com with ESMTP; 29 May 2015 12:26:58 -0700 X-ExtLoop1: 1 X-IronPort-AV: E=Sophos;i="5.13,519,1427785200"; d="scan'208";a="702285021" Received: from lwang14-mobl6.amr.corp.intel.com ([10.127.188.193]) by orsmga001.jf.intel.com with ESMTP; 29 May 2015 12:26:58 -0700 From: Liang-Min Larry Wang <liang-min.wang@intel.com> To: dev@dpdk.org Date: Fri, 29 May 2015 15:26:51 -0400 Message-Id: <1432927612-12244-2-git-send-email-liang-min.wang@intel.com> X-Mailer: git-send-email 2.1.4 In-Reply-To: <1432927612-12244-1-git-send-email-liang-min.wang@intel.com> References: <1432927612-12244-1-git-send-email-liang-min.wang@intel.com> Cc: Liang-Min Larry Wang <liang-min.wang@intel.com> Subject: [dpdk-dev] [PATCH 1/2] ethdev: add api to set default mac address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK <dev.dpdk.org> List-Unsubscribe: <http://dpdk.org/ml/options/dev>, <mailto:dev-request@dpdk.org?subject=unsubscribe> List-Archive: <http://dpdk.org/ml/archives/dev/> List-Post: <mailto:dev@dpdk.org> List-Help: <mailto:dev-request@dpdk.org?subject=help> List-Subscribe: <http://dpdk.org/ml/listinfo/dev>, <mailto:dev-request@dpdk.org?subject=subscribe> Errors-To: dev-bounces@dpdk.org Sender: "dev" <dev-bounces@dpdk.org> |
Commit Message
Liang-Min Larry Wang
May 29, 2015, 7:26 p.m. UTC
add a new api: rte_eth_dev_default_mac_addr_set to
support changing default mac address of a NIC
Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com>
---
lib/librte_ether/rte_ethdev.c | 16 ++++++++++++++++
lib/librte_ether/rte_ethdev.h | 14 ++++++++++++++
lib/librte_ether/rte_ether_version.map | 1 +
3 files changed, 31 insertions(+)
Comments
> -----Original Message----- > From: Wang, Liang-min > Sent: Friday, May 29, 2015 8:27 PM > To: dev@dpdk.org > Cc: Richardson, Bruce; Ananyev, Konstantin; dharton@cisco.com; agh@cisco.com; Wang, Liang-min > Subject: [PATCH 1/2] ethdev: add api to set default mac address > > add a new api: rte_eth_dev_default_mac_addr_set to > support changing default mac address of a NIC > > Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com> > --- > lib/librte_ether/rte_ethdev.c | 16 ++++++++++++++++ > lib/librte_ether/rte_ethdev.h | 14 ++++++++++++++ > lib/librte_ether/rte_ether_version.map | 1 + > 3 files changed, 31 insertions(+) > > diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c > index 024fe8b..96ee00e 100644 > --- a/lib/librte_ether/rte_ethdev.c > +++ b/lib/librte_ether/rte_ethdev.c > @@ -2752,6 +2752,22 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr) > } > > int > +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr) > +{ > + struct rte_eth_dev *dev; > + > + if (!rte_eth_dev_is_valid_port(port_id)) { > + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); > + return -ENODEV; > + } > + > + dev = &rte_eth_devices[port_id]; > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); > + > + return (*dev->dev_ops->mac_addr_set)(dev, addr); > +} As I can see mac_addr_set() is implemented now only for virtio. Which means that for all Intel HW your new rte_eth_dev_default_mac_addr_set() would not work right now? Probably rte_eth_dev_default_mac_addr_set() should combine both approaches: If mac_addr_set() is implemented by dev, then use it, otherwise try to use addr_remove()/addr_add() (as your first version did)? Konstantin > + > +int > rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf, > uint16_t rx_mode, uint8_t on) > { > diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h > index 16dbe00..5f07e0d 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -2982,6 +2982,20 @@ 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. > + */ > +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. > * > * @param port > diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map > index a2d25a6..2dbbaa7 100644 > --- a/lib/librte_ether/rte_ether_version.map > +++ b/lib/librte_ether/rte_ether_version.map > @@ -102,6 +102,7 @@ DPDK_2.0 { > rte_eth_tx_queue_setup; > rte_eth_xstats_get; > rte_eth_xstats_reset; > + rte_eth_dev_default_mac_addr_set; > > local: *; > }; > -- > 2.1.4
2015-06-02 10:52, Ananyev, Konstantin: > From: Wang, Liang-min > > int > > +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr) > > +{ > > + struct rte_eth_dev *dev; > > + > > + if (!rte_eth_dev_is_valid_port(port_id)) { > > + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); > > + return -ENODEV; > > + } > > + > > + dev = &rte_eth_devices[port_id]; > > + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); > > + > > + return (*dev->dev_ops->mac_addr_set)(dev, addr); > > +} > > As I can see mac_addr_set() is implemented now only for virtio. > Which means that for all Intel HW your new rte_eth_dev_default_mac_addr_set() > would not work right now? > Probably rte_eth_dev_default_mac_addr_set() should combine both approaches: > If mac_addr_set() is implemented by dev, then use it, otherwise try to use addr_remove()/addr_add() > (as your first version did)? > Konstantin Not sure it is a good idea to use remove/add to set the default unicast mac address. It would be clearer to add comments to remove/add functions to specify that they don't apply to the default adress but only to secondary ones. Then use the same logic for both API and driver ops. It is the responsibility of the driver implementation to use common functions for default_set and remove/add functions.
>> -----Original Message----- >> From: Wang, Liang-min >> Sent: Friday, May 29, 2015 8:27 PM >> To: dev@dpdk.org >> Cc: Richardson, Bruce; Ananyev, Konstantin; dharton@cisco.com; > >agh@cisco.com; Wang, Liang-min >> Subject: [PATCH 1/2] ethdev: add api to set default mac address > > >> add a new api: rte_eth_dev_default_mac_addr_set to support changing >> default mac address of a NIC > > > >Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com> >> --- > > lib/librte_ether/rte_ethdev.c | 16 ++++++++++++++++ > > lib/librte_ether/rte_ethdev.h | 14 ++++++++++++++ >> lib/librte_ether/rte_ether_version.map | 1 + >> 3 files changed, 31 insertions(+) >> >> diff --git a/lib/librte_ether/rte_ethdev.c >> b/lib/librte_ether/rte_ethdev.c index 024fe8b..96ee00e 100644 >> --- a/lib/librte_ether/rte_ethdev.c >> +++ b/lib/librte_ether/rte_ethdev.c >> @@ -2752,6 +2752,22 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, >> struct ether_addr *addr) } >> >> int >> +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr >> +*addr) { >> + struct rte_eth_dev *dev; >> + >> + if (!rte_eth_dev_is_valid_port(port_id)) { >> + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); >> + return -ENODEV; >> + } >> + >> + dev = &rte_eth_devices[port_id]; >> + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); >> + >> + return (*dev->dev_ops->mac_addr_set)(dev, addr); } >As I can see mac_addr_set() is implemented now only for virtio. >Which means that for all Intel HW your new rte_eth_dev_default_mac_addr_set() >would not work right now? >Probably rte_eth_dev_default_mac_addr_set() should combine both approaches: >If mac_addr_set() is implemented by dev, then use it, otherwise try to use addr_remove()/addr_add() (as your first version did)? >Konstantin The implementation of mac_addr_set() through mac_addr_remove() and mac_addr_add() is very creative, but it may not work for devices other than igb/ixgbe. I will release a patch latter to add hooks on igb and ixgbe(). Just want to keep this interface clean and not to be confined to igb/ixgbe characteristics. > + > +int > rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf, > uint16_t rx_mode, uint8_t on) > { > diff --git a/lib/librte_ether/rte_ethdev.h > b/lib/librte_ether/rte_ethdev.h index 16dbe00..5f07e0d 100644 > --- a/lib/librte_ether/rte_ethdev.h > +++ b/lib/librte_ether/rte_ethdev.h > @@ -2982,6 +2982,20 @@ 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. > + */ > +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. > * > * @param port > diff --git a/lib/librte_ether/rte_ether_version.map > b/lib/librte_ether/rte_ether_version.map > index a2d25a6..2dbbaa7 100644 > --- a/lib/librte_ether/rte_ether_version.map > +++ b/lib/librte_ether/rte_ether_version.map > @@ -102,6 +102,7 @@ DPDK_2.0 { > rte_eth_tx_queue_setup; > rte_eth_xstats_get; > rte_eth_xstats_reset; > + rte_eth_dev_default_mac_addr_set; > > local: *; > }; > -- > 2.1.4
> -----Original Message----- > From: Wang, Liang-min > Sent: Tuesday, June 02, 2015 1:24 PM > To: Ananyev, Konstantin; dev@dpdk.org > Cc: Richardson, Bruce; dharton@cisco.com; agh@cisco.com > Subject: RE: [PATCH 1/2] ethdev: add api to set default mac address > > > >> -----Original Message----- > >> From: Wang, Liang-min > >> Sent: Friday, May 29, 2015 8:27 PM > >> To: dev@dpdk.org > >> Cc: Richardson, Bruce; Ananyev, Konstantin; dharton@cisco.com; > > >agh@cisco.com; Wang, Liang-min > >> Subject: [PATCH 1/2] ethdev: add api to set default mac address > > > > >> add a new api: rte_eth_dev_default_mac_addr_set to support changing > >> default mac address of a NIC > > > > > >Signed-off-by: Liang-Min Larry Wang <liang-min.wang@intel.com> > >> --- > > > lib/librte_ether/rte_ethdev.c | 16 ++++++++++++++++ > > > lib/librte_ether/rte_ethdev.h | 14 ++++++++++++++ > >> lib/librte_ether/rte_ether_version.map | 1 + > >> 3 files changed, 31 insertions(+) > >> > >> diff --git a/lib/librte_ether/rte_ethdev.c > >> b/lib/librte_ether/rte_ethdev.c index 024fe8b..96ee00e 100644 > >> --- a/lib/librte_ether/rte_ethdev.c > >> +++ b/lib/librte_ether/rte_ethdev.c > >> @@ -2752,6 +2752,22 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, > >> struct ether_addr *addr) } > >> > >> int > >> +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr > >> +*addr) { > >> + struct rte_eth_dev *dev; > >> + > >> + if (!rte_eth_dev_is_valid_port(port_id)) { > >> + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); > >> + return -ENODEV; > >> + } > >> + > >> + dev = &rte_eth_devices[port_id]; > >> + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); > >> + > >> + return (*dev->dev_ops->mac_addr_set)(dev, addr); } > > > >As I can see mac_addr_set() is implemented now only for virtio. > >Which means that for all Intel HW your new rte_eth_dev_default_mac_addr_set() > >would not work right now? > >Probably rte_eth_dev_default_mac_addr_set() should combine both approaches: > >If mac_addr_set() is implemented by dev, then use it, otherwise try to use addr_remove()/addr_add() (as your first version did)? > >Konstantin > > The implementation of mac_addr_set() through mac_addr_remove() and mac_addr_add() is very creative, but it may not work for > devices other than igb/ixgbe. I will release a patch latter to add hooks on igb and ixgbe(). Just want to keep this interface clean and not > to be confined to igb/ixgbe characteristics. Ok, if you think it would be more clean way - no objections from me. Konstantin > > > + > > +int > > rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf, > > uint16_t rx_mode, uint8_t on) > > { > > diff --git a/lib/librte_ether/rte_ethdev.h > > b/lib/librte_ether/rte_ethdev.h index 16dbe00..5f07e0d 100644 > > --- a/lib/librte_ether/rte_ethdev.h > > +++ b/lib/librte_ether/rte_ethdev.h > > @@ -2982,6 +2982,20 @@ 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. > > + */ > > +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. > > * > > * @param port > > diff --git a/lib/librte_ether/rte_ether_version.map > > b/lib/librte_ether/rte_ether_version.map > > index a2d25a6..2dbbaa7 100644 > > --- a/lib/librte_ether/rte_ether_version.map > > +++ b/lib/librte_ether/rte_ether_version.map > > @@ -102,6 +102,7 @@ DPDK_2.0 { > > rte_eth_tx_queue_setup; > > rte_eth_xstats_get; > > rte_eth_xstats_reset; > > + rte_eth_dev_default_mac_addr_set; > > > > local: *; > > }; > > -- > > 2.1.4
diff --git a/lib/librte_ether/rte_ethdev.c b/lib/librte_ether/rte_ethdev.c index 024fe8b..96ee00e 100644 --- a/lib/librte_ether/rte_ethdev.c +++ b/lib/librte_ether/rte_ethdev.c @@ -2752,6 +2752,22 @@ rte_eth_dev_mac_addr_remove(uint8_t port_id, struct ether_addr *addr) } int +rte_eth_dev_default_mac_addr_set(uint8_t port_id, struct ether_addr *addr) +{ + struct rte_eth_dev *dev; + + if (!rte_eth_dev_is_valid_port(port_id)) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return -ENODEV; + } + + dev = &rte_eth_devices[port_id]; + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_set, -ENOTSUP); + + return (*dev->dev_ops->mac_addr_set)(dev, addr); +} + +int rte_eth_dev_set_vf_rxmode(uint8_t port_id, uint16_t vf, uint16_t rx_mode, uint8_t on) { diff --git a/lib/librte_ether/rte_ethdev.h b/lib/librte_ether/rte_ethdev.h index 16dbe00..5f07e0d 100644 --- a/lib/librte_ether/rte_ethdev.h +++ b/lib/librte_ether/rte_ethdev.h @@ -2982,6 +2982,20 @@ 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. + */ +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. * * @param port diff --git a/lib/librte_ether/rte_ether_version.map b/lib/librte_ether/rte_ether_version.map index a2d25a6..2dbbaa7 100644 --- a/lib/librte_ether/rte_ether_version.map +++ b/lib/librte_ether/rte_ether_version.map @@ -102,6 +102,7 @@ DPDK_2.0 { rte_eth_tx_queue_setup; rte_eth_xstats_get; rte_eth_xstats_reset; + rte_eth_dev_default_mac_addr_set; local: *; };