From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from mx0b-000f0801.pphosted.com (mx0b-000f0801.pphosted.com [67.231.152.113]) by dpdk.org (Postfix) with ESMTP id 95F89C6FC for ; Fri, 29 Jan 2016 17:18:34 +0100 (CET) Received: from pps.filterd (m0048192.ppops.net [127.0.0.1]) by mx0b-000f0801.pphosted.com (8.15.0.59/8.15.0.59) with SMTP id u0TGHPLu022395 for ; Fri, 29 Jan 2016 08:18:33 -0800 Received: from brmwp-exmb12.corp.brocade.com ([208.47.132.227]) by mx0b-000f0801.pphosted.com with ESMTP id 20qruatn25-1 (version=TLSv1/SSLv3 cipher=AES128-SHA bits=128 verify=NOT) for ; Fri, 29 Jan 2016 08:18:33 -0800 Received: from EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) by BRMWP-EXMB12.corp.brocade.com (172.16.59.130) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Fri, 29 Jan 2016 09:18:32 -0700 Received: from BRA-GXP4P12.brocade.com (10.252.48.16) by EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) with Microsoft SMTP Server (TLS) id 15.0.1104.5; Fri, 29 Jan 2016 17:18:30 +0100 From: Paul Atkins To: Date: Fri, 29 Jan 2016 16:18:11 +0000 Message-ID: <1454084293-5722-2-git-send-email-patkins@brocade.com> X-Mailer: git-send-email 1.7.10.4 In-Reply-To: <1454084293-5722-1-git-send-email-patkins@brocade.com> References: <1454084293-5722-1-git-send-email-patkins@brocade.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [10.252.48.16] X-ClientProxiedBy: hq1wp-excas11.corp.brocade.com (10.70.36.102) To EMEAWP-EXMB11.corp.brocade.com (172.29.11.85) X-Proofpoint-Virus-Version: vendor=fsecure engine=2.50.10432:, , definitions=2016-01-29_06:, , signatures=0 X-Proofpoint-Spam-Details: rule=notspam policy=default score=0 spamscore=0 suspectscore=3 malwarescore=0 phishscore=0 adultscore=0 bulkscore=0 classifier=spam adjust=0 reason=mlx scancount=1 engine=8.0.1-1601100000 definitions=main-1601290271 Subject: [dpdk-dev] [PATCH 1/3] null: add a new arg to allow users to specify ether 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: Fri, 29 Jan 2016 16:18:35 -0000 Add a new argument to the null driver to allow the user to specify the ether address to be used instead of the default which is all zeroes. This also allows the user to specify an address per device instead of them all using the same default one. Signed-off-by: Paul Atkins --- drivers/net/null/rte_eth_null.c | 59 +++++++++++++++++++++++++++++++-------- 1 file changed, 48 insertions(+), 11 deletions(-) diff --git a/drivers/net/null/rte_eth_null.c b/drivers/net/null/rte_eth_null.c index 77fc988..9483d6a 100644 --- a/drivers/net/null/rte_eth_null.c +++ b/drivers/net/null/rte_eth_null.c @@ -41,15 +41,21 @@ #include "rte_eth_null.h" +#include +#include + #define ETH_NULL_PACKET_SIZE_ARG "size" #define ETH_NULL_PACKET_COPY_ARG "copy" +#define ETH_NULL_ETH_ADDR_ARG "eth_addr" static unsigned default_packet_size = 64; static unsigned default_packet_copy; +static struct ether_addr default_eth_addr = { .addr_bytes = {0} }; static const char *valid_arguments[] = { ETH_NULL_PACKET_SIZE_ARG, ETH_NULL_PACKET_COPY_ARG, + ETH_NULL_ETH_ADDR_ARG, NULL }; @@ -69,6 +75,7 @@ struct null_queue { struct pmd_internals { unsigned packet_size; unsigned packet_copy; + struct ether_addr eth_addr; unsigned numa_node; unsigned nb_rx_queues; @@ -89,8 +96,6 @@ struct pmd_internals { uint8_t rss_key[40]; /**< 40-byte hash key. */ }; - -static struct ether_addr eth_addr = { .addr_bytes = {0} }; static const char *drivername = "Null PMD"; static struct rte_eth_link pmd_link = { .link_speed = 10000, @@ -485,11 +490,12 @@ static const struct eth_dev_ops ops = { .rss_hash_conf_get = eth_rss_hash_conf_get }; -int -eth_dev_null_create(const char *name, - const unsigned numa_node, - unsigned packet_size, - unsigned packet_copy) +static int +eth_dev_null_create_internal(const char *name, + const unsigned numa_node, + unsigned packet_size, + unsigned packet_copy, + struct ether_addr eth_addr) { const unsigned nb_rx_queues = 1; const unsigned nb_tx_queues = 1; @@ -539,6 +545,7 @@ eth_dev_null_create(const char *name, internals->nb_tx_queues = nb_tx_queues; internals->packet_size = packet_size; internals->packet_copy = packet_copy; + internals->eth_addr = eth_addr; internals->numa_node = numa_node; internals->flow_type_rss_offloads = ETH_RSS_PROTO_MASK; @@ -551,7 +558,7 @@ eth_dev_null_create(const char *name, data->nb_rx_queues = (uint16_t)nb_rx_queues; data->nb_tx_queues = (uint16_t)nb_tx_queues; data->dev_link = pmd_link; - data->mac_addrs = ð_addr; + data->mac_addrs = &internals->eth_addr; strncpy(data->name, eth_dev->data->name, strlen(eth_dev->data->name)); eth_dev->data = data; @@ -583,6 +590,16 @@ error: return -1; } +int +eth_dev_null_create(const char *name, + const unsigned numa_node, + unsigned packet_size, + unsigned packet_copy) +{ + return eth_dev_null_create_internal(name, numa_node, packet_size, + packet_copy, default_eth_addr); +} + static inline int get_packet_size_arg(const char *key __rte_unused, const char *value, void *extra_args) @@ -617,12 +634,24 @@ get_packet_copy_arg(const char *key __rte_unused, return 0; } +static inline int +get_eth_addr_arg(const char *key __rte_unused, + const char *value, void *extra_args) +{ + if (value == NULL || extra_args == NULL) + return -EINVAL; + + return cmdline_parse_etheraddr(NULL, value, extra_args, + sizeof(struct ether_addr)); +} + static int rte_pmd_null_devinit(const char *name, const char *params) { unsigned numa_node; unsigned packet_size = default_packet_size; unsigned packet_copy = default_packet_copy; + struct ether_addr eth_addr = default_eth_addr; struct rte_kvargs *kvlist = NULL; int ret; @@ -639,7 +668,6 @@ rte_pmd_null_devinit(const char *name, const char *params) return -1; if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_SIZE_ARG) == 1) { - ret = rte_kvargs_process(kvlist, ETH_NULL_PACKET_SIZE_ARG, &get_packet_size_arg, &packet_size); @@ -648,20 +676,29 @@ rte_pmd_null_devinit(const char *name, const char *params) } if (rte_kvargs_count(kvlist, ETH_NULL_PACKET_COPY_ARG) == 1) { - ret = rte_kvargs_process(kvlist, ETH_NULL_PACKET_COPY_ARG, &get_packet_copy_arg, &packet_copy); if (ret < 0) goto free_kvlist; } + + if (rte_kvargs_count(kvlist, ETH_NULL_ETH_ADDR_ARG) == 1) { + ret = rte_kvargs_process(kvlist, + ETH_NULL_ETH_ADDR_ARG, + &get_eth_addr_arg, ð_addr); + if (ret < 0) + goto free_kvlist; + } + } RTE_LOG(INFO, PMD, "Configure pmd_null: packet size is %d, " "packet copy is %s\n", packet_size, packet_copy ? "enabled" : "disabled"); - ret = eth_dev_null_create(name, numa_node, packet_size, packet_copy); + ret = eth_dev_null_create_internal(name, numa_node, packet_size, + packet_copy, eth_addr); free_kvlist: if (kvlist) -- 1.7.10.4