From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mail-pb0-f50.google.com (mail-pb0-f50.google.com [209.85.160.50]) by dpdk.org (Postfix) with ESMTP id AC180B100 for ; Wed, 14 May 2014 20:57:44 +0200 (CEST) Received: by mail-pb0-f50.google.com with SMTP id ma3so2033583pbc.23 for ; Wed, 14 May 2014 11:57:52 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:message-id:user-agent:date:from:to:cc:subject :references:mime-version:content-type:content-disposition; bh=nIkEvFkIv52NSpLTSBkla5BNdsZea/6T8qGd+oualAk=; b=CryBxMyxGqBW12ej9a75pIske6V/Jox5IYtOkIF3hDzrjHzGEVfTploo+lR9C0FfvC aKEjCnN1HFI9ZR/JxYpj4zdTEGMB3mvFYW/xb5j0B8Nn413Qa5Er3/q95CXRagjn4MqH 4+3OTjIVDEY+sUAFNr+E6zzwEAhqn9RG2ucqzBm0ENXKNTgYfvV3zoeROyJ+UaCILaz1 sKB/ZExWi9DBZ7/+d6G1IPJkPkVl5v2bKsN1fnhxCd0X+OSirCEFIo7goOEf4Gd8lhvx VmGB4qw71O3te77oxySgFXts2DNsg2kOmaDxhbZHl9/SgW8gE0+HSLL1X5SNWYDYd5x1 hNig== X-Gm-Message-State: ALoCoQkrb7ssrX0ZbiDtwIbiI4YHhpZ6x0hc3L6FNlGUiggCvbLFqH74o+Ab5O7+drjOGmVRTqUz X-Received: by 10.66.156.34 with SMTP id wb2mr6567267pab.83.1400093872119; Wed, 14 May 2014 11:57:52 -0700 (PDT) Received: from localhost (static-50-53-83-51.bvtn.or.frontiernet.net. [50.53.83.51]) by mx.google.com with ESMTPSA id ey5sm11130690pab.22.2014.05.14.11.57.50 for (version=TLSv1.2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Wed, 14 May 2014 11:57:51 -0700 (PDT) Message-Id: <20140514185750.257523699@networkplumber.org> User-Agent: quilt/0.61-1 Date: Wed, 14 May 2014 11:55:32 -0700 From: Stephen Hemminger To: dev@dpdk.org References: <20140514185527.771828962@networkplumber.org> MIME-Version: 1.0 Content-Type: text/plain; charset=ISO-8859-15 Content-Disposition: inline; filename=mac-addr-set.patch Cc: Stephen Hemminger Subject: [dpdk-dev] [PATCH 5/6] ether: allow setting mac address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: patches and discussions about DPDK List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 14 May 2014 18:57:45 -0000 Allow setting the default Ethernet address used on device. The underlying drivers allow it but the DPDK was blocking any attempts to change Ethernet address on device. For most devices, this is just the same as filling in address in mac address table entry 0, but for some devices this requires special override. Signed-off-by: Stephen Hemminger --- a/lib/librte_ether/rte_ethdev.h 2014-05-14 11:44:27.373014227 -0700 +++ b/lib/librte_ether/rte_ethdev.h 2014-05-14 11:44:27.373014227 -0700 @@ -982,6 +982,11 @@ typedef void (*eth_mac_addr_add_t)(struc struct ether_addr *mac_addr, uint32_t index, uint32_t vmdq); +/**< @internal Change default MAC address */ + +typedef void (*eth_mac_addr_set_t)(struct rte_eth_dev *dev, + struct ether_addr *mac_addr); + /**< @internal Set a MAC address into Receive Address Address Register */ typedef int (*eth_uc_hash_table_set_t)(struct rte_eth_dev *dev, @@ -1114,6 +1119,7 @@ struct eth_dev_ops { priority_flow_ctrl_set_t priority_flow_ctrl_set; /**< Setup priority flow control.*/ eth_mac_addr_remove_t mac_addr_remove; /**< Remove MAC address */ eth_mac_addr_add_t mac_addr_add; /**< Add a MAC address */ + eth_mac_addr_set_t mac_addr_set; /**< Change default MAC address */ eth_uc_hash_table_set_t uc_hash_table_set; /**< Set Unicast Table Array */ eth_uc_all_hash_table_set_t uc_all_hash_table_set; /**< Set Unicast hash bitmap */ eth_mirror_rule_set_t mirror_rule_set; /**< Add a traffic mirror rule.*/ @@ -2538,6 +2544,21 @@ int rte_eth_dev_mac_addr_add(uint8_t por int rte_eth_dev_mac_addr_remove(uint8_t port, struct ether_addr *mac_addr); /** + * Change the default MAC address + * + * @param port + * The port identifier of the Ethernet device. + * @param mac_addr + * MAC address to remove. + * @return + * - (0) if successfully added or *mac_addr" was already added. + * - (-ENOTSUP) if hardware doesn't support this feature. + * - (-ENODEV) if *port* is invalid. + * - (-EINVAL) if MAC address is invalid. + */ +int rte_eth_dev_macaddr_set(uint8_t port, struct ether_addr *mac_addr); + +/** * Update Redirection Table(RETA) of Receive Side Scaling of Ethernet device. * * @param port --- a/lib/librte_ether/rte_ethdev.c 2014-05-14 11:44:27.373014227 -0700 +++ b/lib/librte_ether/rte_ethdev.c 2014-05-14 11:44:27.373014227 -0700 @@ -1059,6 +1059,33 @@ rte_eth_macaddr_get(uint8_t port_id, str } int +rte_eth_dev_macaddr_set(uint8_t port_id, struct ether_addr *addr) +{ + struct rte_eth_dev *dev; + + if (port_id >= nb_ports) { + PMD_DEBUG_TRACE("Invalid port_id=%d\n", port_id); + return (-ENODEV); + } + if (is_zero_ether_addr(addr)) { + PMD_DEBUG_TRACE("port %d: Cannot add NULL MAC address\n", port_id); + return (-EINVAL); + } + dev = &rte_eth_devices[port_id]; + + if (*dev->dev_ops->mac_addr_set) + (*dev->dev_ops->mac_addr_set)(dev, addr); + else { + FUNC_PTR_OR_ERR_RET(*dev->dev_ops->mac_addr_add, -ENOTSUP); + (*dev->dev_ops->mac_addr_add)(dev, addr, 0, 0); + } + + ether_addr_copy(addr, &dev->data->mac_addrs[0]); + + return 0; +} + +int rte_eth_dev_vlan_filter(uint8_t port_id, uint16_t vlan_id, int on) { struct rte_eth_dev *dev;