From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: <3chas3@gmail.com> Received: from mail-qk0-f193.google.com (mail-qk0-f193.google.com [209.85.220.193]) by dpdk.org (Postfix) with ESMTP id E286EC354 for ; Tue, 21 Jun 2016 14:18:51 +0200 (CEST) Received: by mail-qk0-f193.google.com with SMTP id a186so2547388qkf.0 for ; Tue, 21 Jun 2016 05:18:51 -0700 (PDT) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=gmail.com; s=20120113; h=from:to:cc:subject:date:message-id; bh=RGGn5q5ff5UjtZoHZlmpMSKT6LDzitP9ec2nWTT/Q0I=; b=P4aMZyUuBp324QOqn1FqW8DFCfhwQbw+ifFy7qedtIOyslc2nhWIOJ1UQFXtxof0tp mggXuQK5KWa20Zvaft5Pi9MrenWlpWFEWoUlLveUz3nhWuL5J3bDou5QPmoilsVR5yUC cCSHnD7ShL0HKZgrvjV4d7oF1foprABl1+iDTjn+7M0TZvlX3HUxtqxmlrj5CACCs60G OkFT6koFpWxALRdxS3M68gX3GGNQGqc5GpGItH2snKr8VPXK2o10Fa6yL4+ISAeUIT0S PxD/NxL74SmDaMFOOWEZ3/Wour/3F5Xq6FHQzyHtO0+rUVk/kPZV8Am7lmfbxVbtwJHg z1CA== X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:from:to:cc:subject:date:message-id; bh=RGGn5q5ff5UjtZoHZlmpMSKT6LDzitP9ec2nWTT/Q0I=; b=Y+/c4bwE9jWxeyTZ2obcjhmbnp++HiBvzwVyAJcE3gP8tPYGP2tnZ9M7jv1/E9LZs8 DAWNg8iRAgutqAkNpPWJHNnLBSZOiyyrNrbUDa+tec0LNS0NT6G1MTDTQhAvYH+esto/ PEyrMvaZfXE3UPDKf4jj3t6gYics8LHrMoZHfVqMz0jXdUYgyOfsvRGRL01gQzGtjWgy BTmuEnY7KSFIM9HaIMo4b0lmi4+XKoSj1R7/Tud1Sfb+UtHNAGTj3So8mJ4f9eKqjqu7 FzOteU6S6hUf73iIMDVE/hIw6weMFYPWb1bIqksTYk88NVnm+HcyBYwCbF5lnutFOlFf NH2A== X-Gm-Message-State: ALyK8tKta/F/CgprHGz+APQQbLWOCvYH7dvliiblsEGyZV3LTr1cuomlyYMDdA7y4hPNGA== X-Received: by 10.55.98.199 with SMTP id w190mr27817127qkb.75.1466511531439; Tue, 21 Jun 2016 05:18:51 -0700 (PDT) Received: from monolith.home (pool-173-79-169-182.washdc.fios.verizon.net. [173.79.169.182]) by smtp.gmail.com with ESMTPSA id j62sm10105625qtb.35.2016.06.21.05.18.50 (version=TLS1_2 cipher=ECDHE-RSA-AES128-GCM-SHA256 bits=128/128); Tue, 21 Jun 2016 05:18:51 -0700 (PDT) From: Chas Williams <3chas3@gmail.com> To: dev@dpdk.org Cc: harish.patil@qlogic.com, Chas Williams <3chas3@gmail.com> Date: Tue, 21 Jun 2016 08:18:46 -0400 Message-Id: <1466511526-16387-1-git-send-email-3chas3@gmail.com> X-Mailer: git-send-email 2.5.5 Subject: [dpdk-dev] [PATCH] bnx2x: set random MAC address if one isn't assigned 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: Tue, 21 Jun 2016 12:18:52 -0000 If the PF hasn't assigned an address, assign one randomly. While here, convert to use DPDK's ether address utility routines. Fixes: 540a211084a7 ("bnx2x: driver core") Signed-off-by: Chas Williams <3chas3@gmail.com> --- drivers/net/bnx2x/bnx2x.h | 8 -------- drivers/net/bnx2x/bnx2x_vfpf.c | 9 +++++---- drivers/net/bnx2x/bnx2x_vfpf.h | 2 +- 3 files changed, 6 insertions(+), 13 deletions(-) diff --git a/drivers/net/bnx2x/bnx2x.h b/drivers/net/bnx2x/bnx2x.h index 135a6eb..78374e2 100644 --- a/drivers/net/bnx2x/bnx2x.h +++ b/drivers/net/bnx2x/bnx2x.h @@ -1904,14 +1904,6 @@ pci_find_cap(struct bnx2x_softc *sc, uint8_t id, uint8_t type) return NULL; } -static inline int is_valid_ether_addr(uint8_t *addr) -{ - if (!(addr[0] | addr[1] | addr[2] | addr[3] | addr[4] | addr[5])) - return 0; - else - return 1; -} - static inline void bnx2x_set_rx_mode(struct bnx2x_softc *sc) { diff --git a/drivers/net/bnx2x/bnx2x_vfpf.c b/drivers/net/bnx2x/bnx2x_vfpf.c index 14b1d10..89f2fd4 100644 --- a/drivers/net/bnx2x/bnx2x_vfpf.c +++ b/drivers/net/bnx2x/bnx2x_vfpf.c @@ -293,10 +293,11 @@ int bnx2x_vf_get_resources(struct bnx2x_softc *sc, uint8_t tx_count, uint8_t rx_ sc->igu_sb_cnt, sc->igu_base_sb); strncpy(sc->fw_ver, sc_resp.fw_ver, sizeof(sc->fw_ver)); - if (is_valid_ether_addr(sc_resp.resc.current_mac_addr)) - (void)rte_memcpy(sc->link_params.mac_addr, - sc_resp.resc.current_mac_addr, - ETH_ALEN); + if (is_valid_assigned_ether_addr(&sc_resp.resc.current_mac_addr)) + ether_addr_copy(&sc_resp.resc.current_mac_addr, + (struct ether_addr *) sc->link_params.mac_addr); + else + eth_random_addr(sc->link_params.mac_addr); return 0; } diff --git a/drivers/net/bnx2x/bnx2x_vfpf.h b/drivers/net/bnx2x/bnx2x_vfpf.h index 966240c..f854d81 100644 --- a/drivers/net/bnx2x/bnx2x_vfpf.h +++ b/drivers/net/bnx2x/bnx2x_vfpf.h @@ -114,7 +114,7 @@ struct vf_resc { uint8_t num_vlan_filters; uint8_t num_mc_filters; uint8_t permanent_mac_addr[ETH_ALEN]; - uint8_t current_mac_addr[ETH_ALEN]; + struct ether_addr current_mac_addr; uint16_t pf_link_speed; uint32_t pf_link_supported; }; -- 2.5.5