From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM01-BY2-obe.outbound.protection.outlook.com (mail-by2nam01on0050.outbound.protection.outlook.com [104.47.34.50]) by dpdk.org (Postfix) with ESMTP id 9ACAE58D1 for ; Wed, 3 May 2017 13:21:31 +0200 (CEST) Received: from BN3PR03CA0100.namprd03.prod.outlook.com (10.174.66.18) by CY1PR0301MB0906.namprd03.prod.outlook.com (10.160.165.17) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11; Wed, 3 May 2017 11:21:29 +0000 Received: from BN1BFFO11FD007.protection.gbl (2a01:111:f400:7c10::1:163) by BN3PR03CA0100.outlook.office365.com (2603:10b6:400:4::18) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_CBC_SHA256_P256) id 15.1.1075.11 via Frontend Transport; Wed, 3 May 2017 11:21:28 +0000 Authentication-Results: spf=fail (sender IP is 192.88.168.50) smtp.mailfrom=nxp.com; dpdk.org; dkim=none (message not signed) header.d=none;dpdk.org; dmarc=fail action=none header.from=nxp.com; Received-SPF: Fail (protection.outlook.com: domain of nxp.com does not designate 192.88.168.50 as permitted sender) receiver=protection.outlook.com; client-ip=192.88.168.50; helo=tx30smr01.am.freescale.net; Received: from tx30smr01.am.freescale.net (192.88.168.50) by BN1BFFO11FD007.mail.protection.outlook.com (10.58.144.70) with Microsoft SMTP Server (version=TLS1_0, cipher=TLS_RSA_WITH_AES_256_CBC_SHA) id 15.1.1047.9 via Frontend Transport; Wed, 3 May 2017 11:21:28 +0000 Received: from bf-netperf1.ap.freescale.net (bf-netperf1.ap.freescale.net [10.232.134.28]) by tx30smr01.am.freescale.net (8.14.3/8.14.0) with ESMTP id v43BLPth008454; Wed, 3 May 2017 04:21:26 -0700 From: Hemant Agrawal To: CC: Date: Wed, 3 May 2017 16:51:08 +0530 Message-ID: <1493810472-668-1-git-send-email-hemant.agrawal@nxp.com> X-Mailer: git-send-email 1.9.1 X-EOPAttributedMessage: 0 X-Matching-Connectors: 131382840884094247; (91ab9b29-cfa4-454e-5278-08d120cd25b8); () X-Forefront-Antispam-Report: CIP:192.88.168.50; IPV:NLI; CTRY:US; EFV:NLI; SFV:NSPM; SFS:(10009020)(6009001)(336005)(39400400002)(39840400002)(39860400002)(39380400002)(39850400002)(39410400002)(39450400003)(2980300002)(1110001)(1109001)(339900001)(189002)(199003)(9170700003)(81166006)(33646002)(356003)(2351001)(8676002)(50986999)(105606002)(50226002)(4326008)(77096006)(5660300001)(85426001)(189998001)(47776003)(8936002)(5003940100001)(48376002)(106466001)(2906002)(50466002)(86362001)(36756003)(53936002)(305945005)(104016004)(498600001)(38730400002)(6916009)(110136004)(6666003)(217873001); DIR:OUT; SFP:1101; SCL:1; SRVR:CY1PR0301MB0906; H:tx30smr01.am.freescale.net; FPR:; SPF:Fail; MLV:ovrnspm; MX:1; A:1; PTR:InfoDomainNonexistent; LANG:en; X-Microsoft-Exchange-Diagnostics: 1; BN1BFFO11FD007; 1:TbZm/SAw2djkzZCCzm8yO7yyya5SUQgEWR7GVfO3KNjbuyaPqVMZTTInbOMrq80Jd8iMLderNITtH/siju159bHGqeKu1PtfnPjX5WBBnEnfM/JhWmi52JUCEP3zeDwDucX+cOT+vFe67K5R0EdDfegKxnYCJ6J7V+nqYzA9PZAviPEG8PtQt+IZ1dXn6gicEIOZSeBC+8YGR2BaQ9kx/pxNMW0QN6q7zgjXtwroH5ZqFyw2XsVgfLnVSHPiPj53jSP2HXMxhZ8+fTDSdgn07aT+OxLAxPJbQVRcAc8l0dpZ6gL49uf4+4Dz1o0uU8A/Cltdil3ZgjBdDB+JuzTQmXSIcCPY1cc1gi2qr8bqhgNj/rzZQr3jp7ZAudcOc9jH5G8uFtMyY2k3eCJ144offxw3TMMsWdsNHRH45Jry71JmLf4voLCEWvZR4RxcORtXJ1kRCokyfjYYijF5lGm65HBmeeSOlyIOGX7mXq9YHD2Ka6B4a02wpdcGEhrjbmAbEVa0wC1IFoVqGKXxpqd/4c0mpZZfpoYAjmhCrjhOsgIKvrZnIlVqqRz7XGszpEsICkXotlD0CgeYALEs3t8uQl2T6lZPi0rguMNwz4VJ6Z7AYeGZaC2bkCrURoMgla3bGW2V7xhtkb63UQUiwGmFFC/8WeW/xmWvmJo8kd4//X8= MIME-Version: 1.0 Content-Type: text/plain X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5ecfdb3b-6eaa-4ad4-6527-08d492168af1 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(201703131430075)(201703131517081); SRVR:CY1PR0301MB0906; X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0906; 3:3xxByohil+WgbItVIa4x/L2/eAC3D4bmzGCewt5XyJjPgICXAfB/PEpyeLhc8RlvQonelDtL73OukppJ7iAlUzx9vj6IdIHcnrjJkYLVL7fPCrg1Tzu5A+H59Rl216QKbAHdOQun5SSd5ovuWsMkYDDdVSkHMzdWN6MDliVK88OUEfLmtGO3QmkNMnud98ng3ah+SWlpA7n36jEvy4PrQxMtAznBeXPpYvvwnAMbIS1t2mc8/noDmMxQkJaCu2J3kwT7+RymwmWVVjD/P7nVm4zD5xqnS0fHRi/FGssR87RnDW582gBHbpUKpxuRGY9yWbz8SwLNOF7LxC52ACEa8g0BFcFPgcnr0eEc2WPFeQd0fGRqTyi8v5j4Ts675az8u3H2NURRVVANf1f9yxAPwDd24DQDPO6KArz+yHMa33qj0OGvDSzBDWuyKRcXDjFB; 25:54Qg2r5SgfuGPzZvgO0IYgQCVTfybABzcEdFHcrJOV6yqH5B2so+4CwugRWzHhW13u+5mblrdkDc028mriitEJZd5kWanW24ighVxE5NImTUXj+r4HT7LlnI19k4KjtQyCtyLhy5wQIySN4sXoRq5dKN6qaO1eqU/XY1ZUuadsNh38++Vr8r79Tu5Wk855L2xfmZu+/8jmVI3wE2lgtU+y3or2RbpBdpCLXQz7nklxGzFOkEEtgArEplorbVgBBw+btWXA2k5/okrhAXaSmfDLuTeFeojxTeW9ZwimVfguM60VLpNoW5j99yBRfH05Ln8xgiw7FIY051UaTI37jXI85qSPhNHJ81GCcWQRvTVVnzaxKEoiqgNph6GMNWM4XzBLY/WrdJOgxpxVYhZW54TA5FySHaOT/v2gf7Buqr/+LKCPjQiXsKe5O46t/BkShAJ09MywCD9tr6e+uziC8g8g== X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0906; 31:Kz16gjYqz6jIPYjtf5WVfUvy0KSh30hnJl9JO9G9nazSfRoN1uu2Jx2bB8L95CIfuI1yakgQgROVJdkQfUHQLlNESR8onkxhriy8QnkBEFY9C4E2Xj/dHyxiqt9S6R8MK1DMmI6YQpdReAmzRstW5f/HWi5MMakYvcxzliGzzdy70hWWLpOfHpBIi9JlNc8+7q9epckAD73B3bd3sjyfVyFNcFX92/yLqZUtx2geC1b49PgiESH5KkXt7dMdx1T1Ubaj5qe31r6RHAUlPO/OBg== X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-Test: UriScan:(185117386973197); X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(6095135)(601004)(2401047)(8121501046)(13015025)(5005006)(13024025)(13018025)(13023025)(13017025)(10201501046)(3002001)(93006095)(93001095)(6055026)(6096035)(20161123565025)(201703131430075)(201703131433075)(201703131448075)(201703161259150)(201703151042153)(20161123561025)(20161123556025)(20161123563025)(20161123559100); SRVR:CY1PR0301MB0906; BCL:0; PCL:0; RULEID:(400006); SRVR:CY1PR0301MB0906; X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY1PR0301MB0906; 4:VknKWsPJSwV73Pp/X91cbtiHyJcjryrKVCFRW/oG?= =?us-ascii?Q?jkoAgYOgPIpY6yhsK5LwqJXY5Im14JO2uV+Nwbjvva/SkK71RWgNxQlorVor?= =?us-ascii?Q?T+Yme17ljnZB0n8LzHr2D1nLK9w8Mg8KrPu2hCl2d0thrE9o9F+EekVHwK1G?= =?us-ascii?Q?uthgaI+tsqgUuE7/CBX+jjOrCdfsOrOnmFifFmk4PK3GHWCgCL7kwaSKeC7W?= =?us-ascii?Q?Txj+J2q5VlYA7pk0L+rwGG31JPc6E7nGmgdRsUWFtgePvsUWTnGBclQle0ea?= =?us-ascii?Q?nrZms/JrQHfrb8yHzf/1DAfQj5GggHFbN6S3v8aQDwi3vojBclPv+0HDM4k2?= =?us-ascii?Q?FWkf3LQOizykHk/iRw9QBIb5QLg2Ry1T36wgRNqIWz4scrgOCBl8w+W+uFmy?= =?us-ascii?Q?knITSo7Y2cpxlkWaQN5Vnb/uOz27ijYJDrU22JbRkRI+Q8PI2XlNKRKHHNgc?= =?us-ascii?Q?lDFr8sgkTaBFqXtUDbFP8cZVp+MV7s2NK5e+eCOQ+Cu6mAetKsFk2QNzG5oU?= =?us-ascii?Q?bPIM1Qmv1hF86642oL3gj2LXlQRRlpIyd5LZfvX2+oNdszWo0sK0Vk67jQmi?= =?us-ascii?Q?0xotCuuBwKHfc4+i8tPPmmHuK0T90Ad2zUlKV8LEASIZbON6MVkfQB/ka4I3?= =?us-ascii?Q?CO0nfZJ5jdWpDFoNGwajpPNOZNch+42DrR4f5LJrQVV9gbgUWJpTMaXGFyD2?= =?us-ascii?Q?ZnVpNA0u/CSgX3qN96/BPF2fGqw6xXhagrikndSbCqohD3Qu/w7qqbfgThxs?= =?us-ascii?Q?EXZLR+RwArYySe3UwbDA4jrqXrlubbMpdYS92e+g5uTYvfjfi5AuBlXliIy5?= =?us-ascii?Q?fz+1V6kL+Vr5Dn9iXJbY0EZO66rZ3Rz0dtd027PigskwtXGCAraNF0eGsz83?= =?us-ascii?Q?+igvN/PZP52nk/soryykWjAbV97jQNDFHqSXeh/tzGHZRfUvOOVbV4JRig69?= =?us-ascii?Q?rAApHMPcwtg8kPx8in0wzW+Sl1I3XN6hirQ2rWsz4Q=3D=3D?= X-Forefront-PRVS: 029651C7A1 X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; CY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veTvmlpNlXTK2pUcd3XtOk99EDEIi4VZwK/oMyR0Apgl0sc4sk4t0Gvq0bvEO4lJpQYPAhtuaWfXAeAlR1wWZ/WLxOjj59c4Vwq; 24:YNTAGJd/0pV6S5YXU/ng9A9t1NNqaT1+1cTKA5m0zJ5x80VfkInDCOOPy+eVw5iy9keZKe/OlYdTeEY8ZWK4IPa7bOdRRUJ/219a1FJdX0c= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-Microsoft-Exchange-Diagnostics: 1; CY1PR0301MB0906; 7:ZBqW2DMhWovl5Sw21uT1imrsO3Y61/HKQmbxiVqBCd7DvcJ5Co/K/yFuTF6a9ok5A+jLOXeLaTT1QeuE/KSRsS0hBSGtBllNLeFP/XBMv+3yy4kG/pqS0gWzkOgfcyY36tq9aaltlHkRCUfINC1GdNkkS+XWJjrcY/gCKt+kVob751dxU1L9agll6m4llwqo6uuWNz+z7cAmr0wO+xew6EZRi4EKesLjJCe7SlFDhTEMhOqMHGpBeqijyuDyyV4TsE5GAG55FEQQzhAnw75p8We4GOkSGUJPFBebJTd7XUgHjy+4fmvXOlYpNZYjytEj/wthedtrNQR4c2/+3zOVLg== X-MS-Exchange-CrossTenant-OriginalArrivalTime: 03 May 2017 11:21:28.2222 (UTC) X-MS-Exchange-CrossTenant-Id: 5afe0b00-7697-4969-b663-5eab37d5f47e X-MS-Exchange-CrossTenant-OriginalAttributedTenantConnectingIp: TenantId=5afe0b00-7697-4969-b663-5eab37d5f47e; Ip=[192.88.168.50]; Helo=[tx30smr01.am.freescale.net] X-MS-Exchange-CrossTenant-FromEntityHeader: HybridOnPrem X-MS-Exchange-Transport-CrossTenantHeadersStamped: CY1PR0301MB0906 Subject: [dpdk-dev] [RFC PATCH 1/5] kni: change and configure mac address X-BeenThere: dev@dpdk.org X-Mailman-Version: 2.1.15 Precedence: list List-Id: DPDK patches and discussions List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Wed, 03 May 2017 11:21:32 -0000 This patch adds following: 1. option to configure the mac address during create 2. inform usespace, if mac address is being changed in linux Signed-off-by: Hemant Agrawal --- .../linuxapp/eal/include/exec-env/rte_kni_common.h | 3 +++ lib/librte_eal/linuxapp/kni/kni_misc.c | 6 +++++- lib/librte_eal/linuxapp/kni/kni_net.c | 15 +++++++++++++-- lib/librte_kni/rte_kni.c | 12 ++++++++++++ lib/librte_kni/rte_kni.h | 8 ++++++++ 5 files changed, 41 insertions(+), 3 deletions(-) diff --git a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h index 2ac879f..e9fdc73 100644 --- a/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h +++ b/lib/librte_eal/linuxapp/eal/include/exec-env/rte_kni_common.h @@ -80,6 +80,7 @@ enum rte_kni_req_id { RTE_KNI_REQ_UNKNOWN = 0, RTE_KNI_REQ_CHANGE_MTU, RTE_KNI_REQ_CFG_NETWORK_IF, + RTE_KNI_REQ_CHANGE_MAC_ADDR, RTE_KNI_REQ_MAX, }; @@ -92,6 +93,7 @@ struct rte_kni_request { union { uint32_t new_mtu; /**< New MTU */ uint8_t if_up; /**< 1: interface up, 0: interface down */ + uint8_t mac_addr[6]; /**< MAC address for interface */ }; int32_t result; /**< Result for processing request */ } __attribute__((__packed__)); @@ -168,6 +170,7 @@ struct rte_kni_device_info { /* mbuf size */ unsigned mbuf_size; + char macaddr[6]; /**< Mac Address */ }; #define KNI_DEVICE "kni" diff --git a/lib/librte_eal/linuxapp/kni/kni_misc.c b/lib/librte_eal/linuxapp/kni/kni_misc.c index 7590f1f..90879fa 100644 --- a/lib/librte_eal/linuxapp/kni/kni_misc.c +++ b/lib/librte_eal/linuxapp/kni/kni_misc.c @@ -458,12 +458,16 @@ struct kni_net { if (kni->lad_dev) ether_addr_copy(net_dev->dev_addr, kni->lad_dev->dev_addr); - else + else { /* * Generate random mac address. eth_random_addr() is the newer * version of generating mac address in linux kernel. */ random_ether_addr(net_dev->dev_addr); + + /* todo - check if user supplied mac address is available*/ + memcpy(net_dev->dev_addr, dev_info.macaddr, ETH_ALEN); + } ret = register_netdev(net_dev); if (ret) { diff --git a/lib/librte_eal/linuxapp/kni/kni_net.c b/lib/librte_eal/linuxapp/kni/kni_net.c index db9f489..866cbdd 100644 --- a/lib/librte_eal/linuxapp/kni/kni_net.c +++ b/lib/librte_eal/linuxapp/kni/kni_net.c @@ -668,12 +668,23 @@ static int kni_net_set_mac(struct net_device *netdev, void *p) { + int ret; + struct rte_kni_request req; struct sockaddr *addr = p; + struct kni_dev *kni; + + kni = netdev_priv(netdev); + memset(&req, 0, sizeof(req)); + req.req_id = RTE_KNI_REQ_CHANGE_MAC_ADDR; - if (!is_valid_ether_addr((unsigned char *)(addr->sa_data))) + if (!is_valid_ether_addr((unsigned char *)(addr->sa_data))) { return -EADDRNOTAVAIL; + } + memcpy(req.mac_addr, addr->sa_data, netdev->addr_len); memcpy(netdev->dev_addr, addr->sa_data, netdev->addr_len); - return 0; + ret = kni_net_process_request(kni, &req); + + return (ret == 0 ? req.result : ret); } #ifdef HAVE_CHANGE_CARRIER_CB diff --git a/lib/librte_kni/rte_kni.c b/lib/librte_kni/rte_kni.c index 52fcd4b..d5a717b 100644 --- a/lib/librte_kni/rte_kni.c +++ b/lib/librte_kni/rte_kni.c @@ -52,6 +52,10 @@ #define MAX_MBUF_BURST_NUM 32 +#ifndef ETH_ADDR_LEN +#define ETH_ADDR_LEN 6 +#endif + /* Maximum number of ring entries */ #define KNI_FIFO_COUNT_MAX 1024 #define KNI_FIFO_SIZE (KNI_FIFO_COUNT_MAX * sizeof(void *) + \ @@ -368,6 +372,8 @@ struct rte_kni * dev_info.group_id = conf->group_id; dev_info.mbuf_size = conf->mbuf_size; + memcpy(dev_info.macaddr, conf->macaddr, ETH_ADDR_LEN); + snprintf(ctx->name, RTE_KNI_NAMESIZE, "%s", intf_name); snprintf(dev_info.name, RTE_KNI_NAMESIZE, "%s", intf_name); @@ -541,6 +547,11 @@ struct rte_kni * req->result = kni->ops.config_network_if(\ kni->ops.port_id, req->if_up); break; + case RTE_KNI_REQ_CHANGE_MAC_ADDR: /* Change MAC Address */ + if (kni->ops.config_mac_address) + req->result = kni->ops.config_mac_address(kni->ops.port_id, + req->mac_addr); + break; default: RTE_LOG(ERR, KNI, "Unknown request id %u\n", req->req_id); req->result = -EINVAL; @@ -735,6 +746,7 @@ struct rte_kni * kni->ops.change_mtu = NULL; kni->ops.config_network_if = NULL; + kni->ops.config_mac_address = NULL; return 0; } void diff --git a/lib/librte_kni/rte_kni.h b/lib/librte_kni/rte_kni.h index 37deb47..5d2a233 100644 --- a/lib/librte_kni/rte_kni.h +++ b/lib/librte_kni/rte_kni.h @@ -59,6 +59,10 @@ struct rte_kni; struct rte_mbuf; +#ifndef ETH_ADDR_LEN +#define ETH_ADDR_LEN 6 +#endif + /** * Structure which has the function pointers for KNI interface. */ @@ -70,6 +74,9 @@ struct rte_kni_ops { /* Pointer to function of configuring network interface */ int (*config_network_if)(uint8_t port_id, uint8_t if_up); + + /* Pointer to function of configuring mac address */ + int (*config_mac_address)(uint8_t port_id, uint8_t mac_addr[6]); }; /** @@ -87,6 +94,7 @@ struct rte_kni_conf { unsigned mbuf_size; /* mbuf size */ struct rte_pci_addr addr; struct rte_pci_id id; + char macaddr[ETH_ADDR_LEN]; /* MAC address assigned to KNI */ __extension__ uint8_t force_bind : 1; /* Flag to bind kernel thread */ -- 1.9.1