From patchwork Wed Oct 1 14:32:55 2014 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ciprian Barbu X-Patchwork-Id: 38239 Return-Path: X-Original-To: linaro@patches.linaro.org Delivered-To: linaro@patches.linaro.org Received: from mail-wi0-f198.google.com (mail-wi0-f198.google.com [209.85.212.198]) by ip-10-151-82-157.ec2.internal (Postfix) with ESMTPS id B8112202E7 for ; Wed, 1 Oct 2014 14:33:43 +0000 (UTC) Received: by mail-wi0-f198.google.com with SMTP id hi2sf881704wib.9 for ; Wed, 01 Oct 2014 07:33:40 -0700 (PDT) X-Google-DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=1e100.net; s=20130820; h=x-gm-message-state:delivered-to:from:to:date:message-id:in-reply-to :references:subject:precedence:list-id:list-unsubscribe:list-archive :list-post:list-help:list-subscribe:mime-version:errors-to:sender :x-original-sender:x-original-authentication-results:mailing-list :content-type:content-transfer-encoding; bh=ExVftCwGCvKC3/cQJbSkE0OHPB/GPDztCHbfUhkdRmo=; b=j5vo3d2gDanPt8XNTJg44urSwzixG13owlj14kJp4DZw+bmyXcaifdKAJXW9AgZ3Nv 5cH/HNQXb3Oieu+qeMWIweIdH63X1ayoAYXwNdmLih5/2VAZrqhoWijtXZPbFcVdbxZ9 n4ZWZm7nnQ9s8ppF6KLFu+kp1UkTrnWhSJoPyNCnLIfNhoEwzQZavBboq4XcFnoj16qL 4tjyZ98WKuCPkSLX33hV+7WDCMPLvqVJhtJS7W2GbrYsThcn5xROFlXJQ0u2STe3givk Tj97s183Vp9w78kQS1NBncJbCTX+4g5UAUL2whfJiPUYNKbAApMsdDDfOGx/lk7Vps5X ZgzQ== X-Gm-Message-State: ALoCoQmYu0SBOVIuA8gE9XPi5ws/U2yVQQgMZzBdXuytEv5WGubVOlpX9NPWiZK22a1DTdNtAbIP X-Received: by 10.152.4.4 with SMTP id g4mr8338724lag.2.1412174020834; Wed, 01 Oct 2014 07:33:40 -0700 (PDT) X-BeenThere: patchwork-forward@linaro.org Received: by 10.152.36.66 with SMTP id o2ls175094laj.8.gmail; Wed, 01 Oct 2014 07:33:40 -0700 (PDT) X-Received: by 10.152.19.66 with SMTP id c2mr14400212lae.64.1412174020682; Wed, 01 Oct 2014 07:33:40 -0700 (PDT) Received: from mail-la0-f49.google.com (mail-la0-f49.google.com [209.85.215.49]) by mx.google.com with ESMTPS id su1si2044392lbb.33.2014.10.01.07.33.40 for (version=TLSv1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 Oct 2014 07:33:40 -0700 (PDT) Received-SPF: pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) client-ip=209.85.215.49; Received: by mail-la0-f49.google.com with SMTP id q1so468593lam.22 for ; Wed, 01 Oct 2014 07:33:40 -0700 (PDT) X-Received: by 10.152.42.136 with SMTP id o8mr55681235lal.71.1412174020527; Wed, 01 Oct 2014 07:33:40 -0700 (PDT) X-Forwarded-To: patchwork-forward@linaro.org X-Forwarded-For: patch@linaro.org patchwork-forward@linaro.org Delivered-To: patch@linaro.org Received: by 10.112.130.169 with SMTP id of9csp542161lbb; Wed, 1 Oct 2014 07:33:39 -0700 (PDT) X-Received: by 10.224.16.147 with SMTP id o19mr4410210qaa.87.1412174019083; Wed, 01 Oct 2014 07:33:39 -0700 (PDT) Received: from ip-10-35-177-41.ec2.internal (lists.linaro.org. [54.225.227.206]) by mx.google.com with ESMTPS id m6si1812692qaa.127.2014.10.01.07.33.38 for (version=TLSv1 cipher=RC4-SHA bits=128/128); Wed, 01 Oct 2014 07:33:39 -0700 (PDT) Received-SPF: none (google.com: lng-odp-bounces@lists.linaro.org does not designate permitted sender hosts) client-ip=54.225.227.206; Received: from localhost ([127.0.0.1] helo=ip-10-35-177-41.ec2.internal) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XZKyH-0004yy-Jn; Wed, 01 Oct 2014 14:33:37 +0000 Received: from mail-la0-f51.google.com ([209.85.215.51]) by ip-10-35-177-41.ec2.internal with esmtp (Exim 4.76) (envelope-from ) id 1XZKy6-0004ya-OA for lng-odp@lists.linaro.org; Wed, 01 Oct 2014 14:33:27 +0000 Received: by mail-la0-f51.google.com with SMTP id ge10so480175lab.10 for ; Wed, 01 Oct 2014 07:33:20 -0700 (PDT) X-Received: by 10.152.36.4 with SMTP id m4mr56089402laj.17.1412174000789; Wed, 01 Oct 2014 07:33:20 -0700 (PDT) Received: from cipriantemp.enea.se (sestofw01.enea.se. [192.36.1.252]) by mx.google.com with ESMTPSA id tl8sm460985lbb.47.2014.10.01.07.33.19 for (version=TLSv1.1 cipher=ECDHE-RSA-RC4-SHA bits=128/128); Wed, 01 Oct 2014 07:33:20 -0700 (PDT) From: Ciprian Barbu To: lng-odp@lists.linaro.org Date: Wed, 1 Oct 2014 17:32:55 +0300 Message-Id: <1412173976-5238-2-git-send-email-ciprian.barbu@linaro.org> X-Mailer: git-send-email 1.8.3.2 In-Reply-To: <1412173976-5238-1-git-send-email-ciprian.barbu@linaro.org> References: <1412173976-5238-1-git-send-email-ciprian.barbu@linaro.org> X-Topics: patch Subject: [lng-odp] [PATCH 1/2] Remove pktio type awareness X-BeenThere: lng-odp@lists.linaro.org X-Mailman-Version: 2.1.14 Precedence: list List-Id: List-Unsubscribe: , List-Archive: List-Post: , List-Help: , List-Subscribe: , MIME-Version: 1.0 Errors-To: lng-odp-bounces@lists.linaro.org Sender: lng-odp-bounces@lists.linaro.org X-Removed-Original-Auth: Dkim didn't pass. X-Original-Sender: ciprian.barbu@linaro.org X-Original-Authentication-Results: mx.google.com; spf=pass (google.com: domain of patch+caf_=patchwork-forward=linaro.org@linaro.org designates 209.85.215.49 as permitted sender) smtp.mail=patch+caf_=patchwork-forward=linaro.org@linaro.org Mailing-list: list patchwork-forward@linaro.org; contact patchwork-forward+owners@linaro.org X-Google-Group-Id: 836684582541 Signed-off-by: Ciprian Barbu --- example/generator/odp_generator.c | 14 ++- example/ipsec/odp_ipsec.c | 38 ++----- example/l2fwd/odp_l2fwd.c | 30 ++---- example/packet/odp_pktio.c | 44 ++------- platform/linux-generic/include/api/odp_packet_io.h | 4 +- .../linux-generic/include/odp_packet_io_internal.h | 6 -- platform/linux-generic/odp_packet_io.c | 110 +++++++++------------ 7 files changed, 78 insertions(+), 168 deletions(-) diff --git a/example/generator/odp_generator.c b/example/generator/odp_generator.c index 27fc868..78d9df5 100644 --- a/example/generator/odp_generator.c +++ b/example/generator/odp_generator.c @@ -294,8 +294,6 @@ static void *gen_send_thread(void *arg) odp_pktio_t pktio; thread_args_t *thr_args; odp_queue_t outq_def; - odp_pktio_params_t params; - socket_params_t *sock_params = ¶ms.sock_params; odp_buffer_t buf; @@ -303,8 +301,7 @@ static void *gen_send_thread(void *arg) thr_args = arg; /* Open a packet IO instance for this thread */ - sock_params->type = 1; - pktio = odp_pktio_open(thr_args->pktio_dev, thr_args->pool, ¶ms); + pktio = odp_pktio_open(thr_args->pktio_dev, thr_args->pool); if (pktio == ODP_PKTIO_INVALID) { ODP_ERR(" [%02i] Error: pktio create failed\n", thr); return NULL; @@ -454,10 +451,8 @@ static void *gen_recv_thread(void *arg) odp_pktio_t pktio; thread_args_t *thr_args; odp_queue_t inq_def; - odp_pktio_params_t params; char inq_name[ODP_QUEUE_NAME_LEN]; odp_queue_param_t qparam; - socket_params_t *sock_params = ¶ms.sock_params; odp_packet_t pkt; odp_buffer_t buf; @@ -466,8 +461,7 @@ static void *gen_recv_thread(void *arg) thr_args = arg; /* Open a packet IO instance for this thread */ - sock_params->type = 1; - pktio = odp_pktio_open(thr_args->pktio_dev, thr_args->pool, ¶ms); + pktio = odp_pktio_open(thr_args->pktio_dev, thr_args->pool); if (pktio == ODP_PKTIO_INVALID) { ODP_ERR(" [%02i] Error: pktio create failed\n", thr); return NULL; @@ -901,6 +895,10 @@ static void usage(char *progname) "\n" "Optional OPTIONS\n" " -h, --help Display help and exit.\n" + " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" + " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" + " ODP_PKTIO_DISABLE_SOCKET_BASIC\n" + " can be used to advanced pkt I/O selection for linux-generic\n" "\n", NO_PATH(progname), NO_PATH(progname) ); } diff --git a/example/ipsec/odp_ipsec.c b/example/ipsec/odp_ipsec.c index a9bba24..cd94d9a 100644 --- a/example/ipsec/odp_ipsec.c +++ b/example/ipsec/odp_ipsec.c @@ -52,8 +52,6 @@ typedef struct { int core_count; int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ - int type; /**< Packet IO type */ - int fanout; /**< Packet IO fanout */ crypto_api_mode_e mode; /**< Crypto API preferred mode */ odp_buffer_pool_t pool; /**< Buffer pool for packet IO */ } appl_args_t; @@ -540,11 +538,9 @@ void initialize_loop(char *intf) * forwarding database. * * @param intf Interface name string - * @param type Packet IO type (BASIC, MMSG, MMAP) - * @param fanout Packet IO fanout */ static -void initialize_intf(char *intf, int type, int fanout) +void initialize_intf(char *intf) { odp_pktio_t pktio; odp_queue_t outq_def; @@ -552,17 +548,13 @@ void initialize_intf(char *intf, int type, int fanout) char inq_name[ODP_QUEUE_NAME_LEN]; odp_queue_param_t qparam; int ret; - odp_pktio_params_t params; - socket_params_t *sock_params = ¶ms.sock_params; uint8_t src_mac[ODPH_ETHADDR_LEN]; char src_mac_str[MAX_STRING]; /* * Open a packet IO instance for thread and get default output queue */ - sock_params->type = type; - sock_params->fanout = fanout; - pktio = odp_pktio_open(intf, pkt_pool, ¶ms); + pktio = odp_pktio_open(intf, pkt_pool); if (ODP_PKTIO_INVALID == pktio) { ODP_ERR("Error: pktio create failed for %s\n", intf); exit(EXIT_FAILURE); @@ -1292,9 +1284,7 @@ main(int argc, char *argv[]) if (!strncmp("loop", args->appl.if_names[i], strlen("loop"))) initialize_loop(args->appl.if_names[i]); else - initialize_intf(args->appl.if_names[i], - args->appl.type, - args->appl.fanout); + initialize_intf(args->appl.if_names[i]); } /* If we have test streams build them before starting workers */ @@ -1373,12 +1363,10 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) printf("\nParsing command line options\n"); - appl_args->type = 3; /* 3: ODP_PKTIO_TYPE_SOCKET_MMAP */ - appl_args->fanout = 0; /* turn off fanout by default for mmap */ appl_args->mode = 0; /* turn off async crypto API by default */ while (!rc) { - opt = getopt_long(argc, argv, "+c:i:m:t:f:h:r:p:a:e:s:", + opt = getopt_long(argc, argv, "+c:i:m:h:r:p:a:e:s:", longopts, &long_index); if (-1 == opt) @@ -1431,14 +1419,6 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) } break; - case 't': - appl_args->type = atoi(optarg); - break; - - case 'f': - appl_args->fanout = atoi(optarg); - break; - case 'm': appl_args->mode = atoi(optarg); break; @@ -1536,12 +1516,6 @@ static void usage(char *progname) "\n" "Mandatory OPTIONS:\n" " -i, --interface Eth interfaces (comma-separated, no spaces)\n" - " -t, --type 1: ODP_PKTIO_TYPE_SOCKET_BASIC\n" - " 2: ODP_PKTIO_TYPE_SOCKET_MMSG\n" - " 3: ODP_PKTIO_TYPE_SOCKET_MMAP\n" - " 4: ODP_PKTIO_TYPE_NETMAP\n" - " Default: 3: ODP_PKTIO_TYPE_SOCKET_MMAP\n" - " -f, --fanout 0: off 1: on (Default 1: on)\n" " -m, --mode 0: SYNC\n" " 1: ASYNC_IN_PLACE\n" " 2: ASYNC_NEW_BUFFER\n" @@ -1568,6 +1542,10 @@ static void usage(char *progname) "Optional OPTIONS\n" " -c, --count Core count.\n" " -h, --help Display help and exit.\n" + " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" + " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" + " ODP_PKTIO_DISABLE_SOCKET_BASIC\n" + " can be used to advanced pkt I/O selection for linux-generic\n" "\n", NO_PATH(progname), NO_PATH(progname) ); } diff --git a/example/l2fwd/odp_l2fwd.c b/example/l2fwd/odp_l2fwd.c index 6c1d64a..fb325c4 100644 --- a/example/l2fwd/odp_l2fwd.c +++ b/example/l2fwd/odp_l2fwd.c @@ -122,15 +122,11 @@ static void usage(char *progname); static odp_pktio_t burst_mode_init_params(void *arg, odp_buffer_pool_t pool) { thread_args_t *args; - odp_pktio_params_t params; - socket_params_t *sock_params = ¶ms.sock_params; odp_pktio_t pktio; args = arg; /* Open a packet IO instance for this thread */ - sock_params->type = args->type; - sock_params->fanout = args->fanout; - pktio = odp_pktio_open(args->srcif, pool, ¶ms); + pktio = odp_pktio_open(args->srcif, pool); if (pktio == ODP_PKTIO_INVALID) ODP_ERR(" Error: pktio create failed"); @@ -417,8 +413,6 @@ int main(int argc, char *argv[]) gbl_args->thread[i].dstif = gbl_args->appl.if_names[if_idx-1]; gbl_args->thread[i].pool = pool; gbl_args->thread[i].mode = gbl_args->appl.mode; - gbl_args->thread[i].type = gbl_args->appl.type; - gbl_args->thread[i].fanout = gbl_args->appl.fanout; if (gbl_args->appl.mode == APPL_MODE_PKT_BURST) { pktio = burst_mode_init_params(&gbl_args->thread[i], pool); @@ -518,11 +512,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) }; appl_args->mode = -1; /* Invalid, must be changed by parsing */ - appl_args->type = 3; /* 3: ODP_PKTIO_TYPE_SOCKET_MMAP */ - appl_args->fanout = 1; /* turn off fanout by default for mmap */ while (1) { - opt = getopt_long(argc, argv, "+c:i:m:t:f:h", + opt = getopt_long(argc, argv, "+c:i:m:h", longopts, &long_index); if (opt == -1) @@ -583,14 +575,6 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->mode = APPL_MODE_PKT_QUEUE; break; - case 't': - appl_args->type = atoi(optarg); - break; - - case 'f': - appl_args->fanout = atoi(optarg); - break; - case 'h': usage(argv[0]); exit(EXIT_SUCCESS); @@ -663,16 +647,14 @@ static void usage(char *progname) " -i, --interface Eth interfaces (comma-separated, no spaces)\n" " -m, --mode 0: Burst send&receive packets (no queues)\n" " 1: Send&receive packets through ODP queues.\n" - " -t, --type 1: ODP_PKTIO_TYPE_SOCKET_BASIC\n" - " 2: ODP_PKTIO_TYPE_SOCKET_MMSG\n" - " 3: ODP_PKTIO_TYPE_SOCKET_MMAP\n" - " 4: ODP_PKTIO_TYPE_NETMAP\n" - " Default: 3: ODP_PKTIO_TYPE_SOCKET_MMAP\n" - " -f, --fanout 0: off 1: on (Default 1: on)\n" "\n" "Optional OPTIONS\n" " -c, --count Core count.\n" " -h, --help Display help and exit.\n\n" + " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" + " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" + " ODP_PKTIO_DISABLE_SOCKET_BASIC\n" + " can be used to advanced pkt I/O selection for linux-generic\n" "\n", NO_PATH(progname), NO_PATH(progname) ); } diff --git a/example/packet/odp_pktio.c b/example/packet/odp_pktio.c index 41315f7..3ab4820 100644 --- a/example/packet/odp_pktio.c +++ b/example/packet/odp_pktio.c @@ -68,8 +68,6 @@ typedef struct { int if_count; /**< Number of interfaces to be used */ char **if_names; /**< Array of pointers to interface names */ int mode; /**< Packet IO mode */ - int type; /**< Packet IO type */ - int fanout; /**< Packet IO fanout */ odp_buffer_pool_t pool; /**< Buffer pool for packet IO */ } appl_args_t; @@ -80,8 +78,6 @@ typedef struct { char *pktio_dev; /**< Interface name to use */ odp_buffer_pool_t pool; /**< Buffer pool for packet IO */ int mode; /**< Thread mode */ - int type; /**< Thread i/o type */ - int fanout; /**< Thread i/o fanout */ } thread_args_t; /** @@ -124,8 +120,6 @@ static void *pktio_queue_thread(void *arg) int ret; unsigned long pkt_cnt = 0; unsigned long err_cnt = 0; - odp_pktio_params_t params; - socket_params_t *sock_params = ¶ms.sock_params; thr = odp_thread_id(); thr_args = arg; @@ -141,9 +135,7 @@ static void *pktio_queue_thread(void *arg) } /* Open a packet IO instance for this thread */ - sock_params->type = thr_args->type; - sock_params->fanout = thr_args->fanout; - pktio = odp_pktio_open(thr_args->pktio_dev, pkt_pool, ¶ms); + pktio = odp_pktio_open(thr_args->pktio_dev, pkt_pool); if (pktio == ODP_PKTIO_INVALID) { ODP_ERR(" [%02i] Error: pktio create failed\n", thr); return NULL; @@ -212,7 +204,7 @@ static void *pktio_queue_thread(void *arg) odp_queue_enq(outq_def, buf); /* Print packet counts every once in a while */ - if (odp_unlikely(pkt_cnt++ % 100000 == 0)) { + if (odp_unlikely(pkt_cnt++ % 1 == 0)) { printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); fflush(NULL); } @@ -237,8 +229,6 @@ static void *pktio_ifburst_thread(void *arg) unsigned long pkt_cnt = 0; unsigned long err_cnt = 0; unsigned long tmp = 0; - odp_pktio_params_t params; - socket_params_t *sock_params = ¶ms.sock_params; thr = odp_thread_id(); thr_args = arg; @@ -254,9 +244,7 @@ static void *pktio_ifburst_thread(void *arg) } /* Open a packet IO instance for this thread */ - sock_params->type = thr_args->type; - sock_params->fanout = thr_args->fanout; - pktio = odp_pktio_open(thr_args->pktio_dev, pkt_pool, ¶ms); + pktio = odp_pktio_open(thr_args->pktio_dev, pkt_pool); if (pktio == ODP_PKTIO_INVALID) { ODP_ERR(" [%02i] Error: pktio create failed.\n", thr); return NULL; @@ -283,7 +271,7 @@ static void *pktio_ifburst_thread(void *arg) /* Print packet counts every once in a while */ tmp += pkts_ok; - if (odp_unlikely((tmp >= 100000) || /* OR first print:*/ + if (odp_unlikely((tmp >= 1) || /* OR first print:*/ ((pkt_cnt == 0) && ((tmp-1) < MAX_PKT_BURST)))) { pkt_cnt += tmp; printf(" [%02i] pkt_cnt:%lu\n", thr, pkt_cnt); @@ -395,8 +383,6 @@ int main(int argc, char *argv[]) args->thread[i].pktio_dev = args->appl.if_names[if_idx]; args->thread[i].pool = pool; args->thread[i].mode = args->appl.mode; - args->thread[i].type = args->appl.type; - args->thread[i].fanout = args->appl.fanout; if (args->appl.mode == APPL_MODE_PKT_BURST) thr_run_func = pktio_ifburst_thread; @@ -510,11 +496,9 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) }; appl_args->mode = -1; /* Invalid, must be changed by parsing */ - appl_args->type = 3; /* 3: ODP_PKTIO_TYPE_SOCKET_MMAP */ - appl_args->fanout = 1; /* turn off fanout by default for mmap */ while (1) { - opt = getopt_long(argc, argv, "+c:i:m:t:f:h", + opt = getopt_long(argc, argv, "+c:i:m:h", longopts, &long_index); if (opt == -1) @@ -575,14 +559,6 @@ static void parse_args(int argc, char *argv[], appl_args_t *appl_args) appl_args->mode = APPL_MODE_PKT_QUEUE; break; - case 't': - appl_args->type = atoi(optarg); - break; - - case 'f': - appl_args->fanout = atoi(optarg); - break; - case 'h': usage(argv[0]); exit(EXIT_SUCCESS); @@ -652,16 +628,14 @@ static void usage(char *progname) " -i, --interface Eth interfaces (comma-separated, no spaces)\n" " -m, --mode 0: Burst send&receive packets (no queues)\n" " 1: Send&receive packets through ODP queues.\n" - " -t, --type 1: ODP_PKTIO_TYPE_SOCKET_BASIC\n" - " 2: ODP_PKTIO_TYPE_SOCKET_MMSG\n" - " 3: ODP_PKTIO_TYPE_SOCKET_MMAP\n" - " 4: ODP_PKTIO_TYPE_NETMAP\n" - " Default: 3: ODP_PKTIO_TYPE_SOCKET_MMAP\n" - " -f, --fanout 0: off 1: on (Default 1: on)\n" "\n" "Optional OPTIONS\n" " -c, --count Core count.\n" " -h, --help Display help and exit.\n" + " environment variables: ODP_PKTIO_DISABLE_SOCKET_MMAP\n" + " ODP_PKTIO_DISABLE_SOCKET_MMSG\n" + " ODP_PKTIO_DISABLE_SOCKET_BASIC\n" + " can be used to advanced pkt I/O selection for linux-generic\n" "\n", NO_PATH(progname), NO_PATH(progname) ); } diff --git a/platform/linux-generic/include/api/odp_packet_io.h b/platform/linux-generic/include/api/odp_packet_io.h index cfefac0..9f9e754 100644 --- a/platform/linux-generic/include/api/odp_packet_io.h +++ b/platform/linux-generic/include/api/odp_packet_io.h @@ -36,12 +36,10 @@ typedef uint32_t odp_pktio_t; * * @param dev Packet IO device * @param pool Pool to use for packet IO - * @param params Set of parameters to pass to the arch dependent implementation * * @return ODP packet IO handle or ODP_PKTIO_INVALID on error */ -odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, - odp_pktio_params_t *params); +odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool); /** * Close an ODP packet IO instance diff --git a/platform/linux-generic/include/odp_packet_io_internal.h b/platform/linux-generic/include/odp_packet_io_internal.h index 881cc5f..7ba72df 100644 --- a/platform/linux-generic/include/odp_packet_io_internal.h +++ b/platform/linux-generic/include/odp_packet_io_internal.h @@ -20,9 +20,6 @@ extern "C" { #include #include -#ifdef ODP_HAVE_NETMAP -#include -#endif struct pktio_entry { odp_spinlock_t lock; /**< entry spinlock */ @@ -32,9 +29,6 @@ struct pktio_entry { odp_pktio_params_t params; /**< pktio parameters */ pkt_sock_t pkt_sock; /**< using socket API for IO */ pkt_sock_mmap_t pkt_sock_mmap; /**< using socket mmap API for IO */ -#ifdef ODP_HAVE_NETMAP - pkt_netmap_t pkt_nm; /**< using netmap API for IO */ -#endif }; typedef union { diff --git a/platform/linux-generic/odp_packet_io.c b/platform/linux-generic/odp_packet_io.c index c06653f..719e1d0 100644 --- a/platform/linux-generic/odp_packet_io.c +++ b/platform/linux-generic/odp_packet_io.c @@ -109,32 +109,16 @@ static void unlock_entry(pktio_entry_t *entry) odp_spinlock_unlock(&entry->s.lock); } -static void init_pktio_entry(pktio_entry_t *entry, odp_pktio_params_t *params) +static void init_pktio_entry(pktio_entry_t *entry) { set_taken(entry); entry->s.inq_default = ODP_QUEUE_INVALID; - switch (params->type) { - case ODP_PKTIO_TYPE_SOCKET_BASIC: - case ODP_PKTIO_TYPE_SOCKET_MMSG: - case ODP_PKTIO_TYPE_SOCKET_MMAP: - memset(&entry->s.pkt_sock, 0, sizeof(entry->s.pkt_sock)); - memset(&entry->s.pkt_sock_mmap, 0, - sizeof(entry->s.pkt_sock_mmap)); - break; -#ifdef ODP_HAVE_NETMAP - case ODP_PKTIO_TYPE_NETMAP: - memset(&entry->s.pkt_nm, 0, sizeof(entry->s.pkt_nm)); - break; -#endif - default: - ODP_ERR("Packet I/O type not supported. Please recompile\n"); - break; - } - /* Save pktio parameters, type is the most useful */ - memcpy(&entry->s.params, params, sizeof(*params)); + memset(&entry->s.params, 0, sizeof(entry->s.params)); + memset(&entry->s.pkt_sock, 0, sizeof(entry->s.pkt_sock)); + memset(&entry->s.pkt_sock_mmap, 0, sizeof(entry->s.pkt_sock_mmap)); } -static odp_pktio_t alloc_lock_pktio_entry(odp_pktio_params_t *params) +static odp_pktio_t alloc_lock_pktio_entry(void) { odp_pktio_t id; pktio_entry_t *entry; @@ -145,7 +129,7 @@ static odp_pktio_t alloc_lock_pktio_entry(odp_pktio_params_t *params) if (is_free(entry)) { lock_entry(entry); if (is_free(entry)) { - init_pktio_entry(entry, params); + init_pktio_entry(entry); id = i + 1; return id; /* return with entry locked! */ } @@ -168,30 +152,14 @@ static int free_pktio_entry(odp_pktio_t id) return 0; } -odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, - odp_pktio_params_t *params) +odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool) { odp_pktio_t id; pktio_entry_t *pktio_entry; int res; + int fanout = 1; - if (params == NULL) { - ODP_ERR("Invalid pktio params\n"); - return ODP_PKTIO_INVALID; - } - - switch (params->type) { - case ODP_PKTIO_TYPE_SOCKET_BASIC: - case ODP_PKTIO_TYPE_SOCKET_MMSG: - case ODP_PKTIO_TYPE_SOCKET_MMAP: - ODP_DBG("Allocating socket pktio\n"); - break; - default: - ODP_ERR("Invalid pktio type: %02x\n", params->type); - return ODP_PKTIO_INVALID; - } - - id = alloc_lock_pktio_entry(params); + id = alloc_lock_pktio_entry(); if (id == ODP_PKTIO_INVALID) { ODP_ERR("No resources available.\n"); return ODP_PKTIO_INVALID; @@ -200,33 +168,51 @@ odp_pktio_t odp_pktio_open(const char *dev, odp_buffer_pool_t pool, pktio_entry = get_entry(id); - switch (params->type) { - case ODP_PKTIO_TYPE_SOCKET_BASIC: - case ODP_PKTIO_TYPE_SOCKET_MMSG: + ODP_DBG("ODP_PKTIO_USE_FANOUT: %d\n", fanout); + if (getenv("ODP_PKTIO_DISABLE_SOCKET_MMAP") == NULL) { + pktio_entry->s.params.sock_params.type = + ODP_PKTIO_TYPE_SOCKET_MMAP; + pktio_entry->s.params.sock_params.fanout = fanout; + res = setup_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, dev, + pool, fanout); + if (res != -1) { + ODP_DBG("IO type: ODP_PKTIO_TYPE_SOCKET_MMAP\n"); + goto done; + } + close_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap); + } + + if (getenv("ODP_PKTIO_DISABLE_SOCKET_MMSG") == NULL) { + pktio_entry->s.params.sock_params.type = + ODP_PKTIO_TYPE_SOCKET_MMSG; + pktio_entry->s.params.sock_params.fanout = fanout; res = setup_pkt_sock(&pktio_entry->s.pkt_sock, dev, pool); - if (res == -1) { - close_pkt_sock(&pktio_entry->s.pkt_sock); - free_pktio_entry(id); - id = ODP_PKTIO_INVALID; + if (res != -1) { + ODP_DBG("IO type: ODP_PKTIO_TYPE_SOCKET_MMSG\n"); + goto done; } - break; - case ODP_PKTIO_TYPE_SOCKET_MMAP: - res = setup_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap, dev, - pool, params->sock_params.fanout); - if (res == -1) { - close_pkt_sock_mmap(&pktio_entry->s.pkt_sock_mmap); - free_pktio_entry(id); - id = ODP_PKTIO_INVALID; + close_pkt_sock(&pktio_entry->s.pkt_sock); + } + + if (getenv("ODP_PKTIO_DISABLE_SOCKET_BASIC") == NULL) { + pktio_entry->s.params.sock_params.type = + ODP_PKTIO_TYPE_SOCKET_BASIC; + pktio_entry->s.params.sock_params.fanout = fanout; + res = setup_pkt_sock(&pktio_entry->s.pkt_sock, dev, pool); + if (res != -1) { + ODP_DBG("IO type: ODP_PKTIO_TYPE_SOCKET_BASIC\n"); + goto done; } - break; - default: - free_pktio_entry(id); - id = ODP_PKTIO_INVALID; - ODP_ERR("This type of I/O is not supported. Please recompile.\n"); - break; + close_pkt_sock(&pktio_entry->s.pkt_sock); } unlock_entry(pktio_entry); + free_pktio_entry(id); + ODP_ERR("Unable to init any I/O type.\n"); + return ODP_PKTIO_INVALID; + +done: + unlock_entry(pktio_entry); return id; }