From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0051.outbound.protection.outlook.com [104.47.36.51]) by dpdk.org (Postfix) with ESMTP id D27B41B215 for ; Sun, 8 Oct 2017 14:45:50 +0200 (CEST) DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=CAVIUMNETWORKS.onmicrosoft.com; s=selector1-cavium-com; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version; bh=pqZ4ZrJoQ1B3EqAKMaKpyZr+O/ONCn+WpQIuXyD1oV0=; b=iXFbvRRvtgxIdngGm/Fkd+kGY2/wrYyVjiGTa2j5oadPripoi01JNkhi8XjfuLULweEXOl7pVStifuMANlT23PZvp+4Yx+AeiccDdGNp0OvfnDQumHyGSVQlLBhSSRMLyeB5VHOgq1WCAV1nwASHjYPxRTdHu+s+lsiZltaX9cg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Santosh.Shukla@cavium.com; Received: from localhost.localdomain (14.140.2.178) by BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.77.7; Sun, 8 Oct 2017 12:45:47 +0000 From: Santosh Shukla To: dev@dpdk.org Cc: ferruh.yigit@intel.com, jerin.jacob@caviumnetworks.com, Santosh Shukla Date: Sun, 8 Oct 2017 18:14:15 +0530 Message-Id: <20171008124430.1866-12-santosh.shukla@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20171008124430.1866-1-santosh.shukla@caviumnetworks.com> References: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> <20171008124430.1866-1-santosh.shukla@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [14.140.2.178] X-ClientProxiedBy: MA1PR01CA0113.INDPRD01.PROD.OUTLOOK.COM (10.174.56.157) To BN6PR07MB3089.namprd07.prod.outlook.com (10.172.105.7) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 1271683e-3261-4fac-ec9c-08d50e4a8099 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:BN6PR07MB3089; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 3:CVqoe3Rid5uHFSrFBOq+ehLGQ6V5t/VhqPu1pH2LW4iqeO2rVlxHP7kqa9HpsNAbiA/o2svBeJXPiM1oWR0xMPVQvsrquVXrO3XDuF23fl3PqhMgwcPPMZ17oPJhq9mo0nUccff5Pj7GJw+FpsWXxWk8WOSUSOvop3HWtbarwqSAOpp5xqT9niGp7p1dIf2fkWH2AE9wOSRxs9fA+VF5HKAa9aJEK6guF6M1ablo1JsMNqOMWycEgaEfap8C0MBQ; 25:9OeGgSBFBO95c3L4FS88wpQ6Ns7bUYSQGjlTUNAW6G4uLkr4sn8AQsWhhtsAb1xu1YfhferXC3tNPLdjwYshVv4kZj2vcx5DVd/9tkCBH9SmoHweHO4fUgnzc5JIvPh7vR21FzgjjvLRalQL2kGXjN0gvRhg7fY4f07xIbKTWFnhGBFkPZbhy2PNDnK+F/C8VXjQCgNcrMCKQpzh8fSRQUljkpYj/+nwP6mn/muI7nc++5qgJlt2cuY0Vm5ViIMsFpts0No41+QFCxMmMaBW9FQmO2GPZJT4nSEDDe1agAHmOHLr+zDSrh1d8v5S0ZL68Bb/EZ66Dh7YJHvbjqMMKA==; 31:56CMRbMKd6ZEen/6PM/2RKlTSy3ety80Xldu4Aua4vZ9fxgrwuno0w5HgVGysO3ajethQY4Zis+ne+acc7rpSU7x96+pt8+oTxIn04mLOAmx3vARx4g2jem/zdyjrUIfI8himt3k7tMaifaUijnAa+EzdIzNXbQI5B2kzNQRQjOJ9khR6FYuFEjdAewdPyDTIdpdcU1ZryVLJr67JQ8CLZjIqJorSu6tPJKo+pp5wsI= X-MS-TrafficTypeDiagnostic: BN6PR07MB3089: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 20:W5GsfWsAtCq2DgxjawSB27ev3aFO6z4RA+5Bfq91uZm2zPT3V7OtcNJ0fTnEo/MXiNq1tOkFIYJzDxEK4NQ0a3t4TBINQLoEIQYN7QPd8dSmDDewMulXaOl9PLLU8Sw1+ljdXuon2slyTFw5LrOZ1YnfWorG/1OVbrcL/hCI4tcPyYSop2h0WQvU2xHSswTuurm4nAGdJeMnz6oCkEOlo2FVSEEzTpCto2jkexEJy5vSgxY9W3BaywpNBp7peC3nlUqrEiSgU/DasswLLH6CO8+VHlULqTzlqxD09od0i3X+M6FeVzcB1uLU4TEEkV/s1ccpQh+NfvCNcTXdeHq+bmI3RdMjUGUTdgQggsWR+2q2QYXsnHqLKiuf/jv5pcGyYz7TcMcGWfQX6bA9xYNKc2IaElflSu45xaPX8/eIzxflZSKQWcDYQwFFWfVrs0ShKAiZyiRgfc8N4zH8RGpRhH5bV2S31S1fwVUOlR95/lNYlBWqEB+beAOjeKRujsXgn9f/2QMYUkBJSUUXON8LeptwVi+CY8FFQezdJg7lBYr4F7QAorAfAi44Bi4RD5tCwqcoOeo+XUABvF8CqcbR9DXCastHQfKegAx+3E6gbD4=; 4:6A/VRtnocy64kNXJcT4MPzPhxqX5cVstuuFMazsCkxMo/kEdMWm8XGfCOKBnganUsNgmDN96cC0IP6xL9Dgog6DLoZgvCogfzYTIr/7mjfjrqgnWeXXiVv0ZjqiKJtjZijItqlkHWoziLmjeDCGpRxCPW6Nqrrp40YzxllNriR+l2SjULfpx8BR+3vp503EdP6ejyn6fQYQuFqe7NLyeb3gExIL5oLoJzNYqm1ZP+dThltkrYQLg2iKRrYl714or X-Exchange-Antispam-Report-Test: UriScan:; X-Microsoft-Antispam-PRVS: X-Exchange-Antispam-Report-CFA-Test: BCL:0; PCL:0; RULEID:(100000700101)(100105000095)(100000701101)(100105300095)(100000702101)(100105100095)(6040450)(2401047)(8121501046)(5005006)(3002001)(10201501046)(93006095)(100000703101)(100105400095)(6041248)(20161123562025)(20161123558100)(20161123564025)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123555025)(20161123560025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:BN6PR07MB3089; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:BN6PR07MB3089; X-Forefront-PRVS: 0454444834 X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6069001)(6009001)(376002)(346002)(199003)(189002)(6916009)(42882006)(81166006)(575784001)(2950100002)(81156014)(8936002)(50226002)(6486002)(16526018)(6666003)(189998001)(16586007)(316002)(6116002)(1076002)(6506006)(3846002)(7736002)(305945005)(8676002)(106356001)(105586002)(5009440100003)(53936002)(4326008)(66066001)(107886003)(47776003)(2906002)(5660300001)(6512007)(76176999)(5003940100001)(50986999)(97736004)(25786009)(101416001)(68736007)(48376002)(50466002)(478600001)(72206003)(2351001)(2361001)(33646002)(36756003)(110426004); DIR:OUT; SFP:1101; SCL:1; SRVR:BN6PR07MB3089; H:localhost.localdomain; FPR:; SPF:None; PTR:InfoNoRecords; A:1; MX:1; LANG:en; Received-SPF: None (protection.outlook.com: cavium.com does not designate permitted sender hosts) X-Microsoft-Exchange-Diagnostics: =?us-ascii?Q?1; BN6PR07MB3089; 23:FV59V54+d3YGP65BQUY9HFx7ZluGVLYjRik3cOoXg?= =?us-ascii?Q?dfBk9NhK1q+8OWr4VfrF+9WYzCj14ByrN2lobBC2Zw2L3ZucMMCrqF59MZuK?= =?us-ascii?Q?ed1b1lDPaDZ+C0S8u4HFYEfTEjbzYV1OyHyj0t43U9RCN5Wy7Np86kz1D83S?= =?us-ascii?Q?9jwwDS4JoiqejT7X0kG52SYd7Kutlu6iWi6eKDbr9BnhFMpCXhydtcFRvgPf?= =?us-ascii?Q?m0p8e8FHvFvlZ0oq3YZUwgLtdWSNtbyj9nSC/KpqfiScPDiUsE72NVaKQm7/?= =?us-ascii?Q?4uclHdqXalJcM5ApKsGImpUwLJGpqCU/NOsPwn04uth1Hz8oku+Feu2nlGI0?= =?us-ascii?Q?fKj+BuZeF3Na0ludSppdBFQZW+zZvXfDIguIddBYiHR9eJ5m8eAf1Y6pBgFw?= =?us-ascii?Q?5Bdrf+NLSCT5hXnyzO+ow+LLNM6FwcycqpT6vMDm0V0oMYe9oGD4WPLQBa2u?= =?us-ascii?Q?BMGb3XKo4n0WwZJ65EuxRievX+X/JokAmBqBCev5MC9FcitMICH/eZcOoZHN?= =?us-ascii?Q?5v8XjgZilNv9KOV/B9j5ZDbBBV6C4amKpNeSShOVky5pxqPRvFW+FV0wa1eR?= =?us-ascii?Q?9WXCWY+72ZvluCT9t4Jq1belWw6pJaNNjP2ja3wK2i0dkqqmZI/BmAe3DODL?= =?us-ascii?Q?p/M/XQ3n5zG4Etzgv147GY9chf2rfXddWFuZaehntag6YI0HfNdBQsoNj680?= =?us-ascii?Q?IholzuPu3MrT2bdiXn7SZxXp8IAxGLAoeIpThzRE4g7tAGuVnh9/i5JChtBY?= =?us-ascii?Q?MyyLChm4McXiFZEQ8HAt4zRH/C9zVxeBayExIoJlRJJt+R4IeVOb1D2NgtrA?= =?us-ascii?Q?90tgpokja/aOcPsTddcVmSv6cAI+obBocjDI2Va2lMWYyYN42o1ygG4RgQjF?= =?us-ascii?Q?ERAuAJRu2a8Al8S8XBkI9NLhd8e275PeuEDo6OHHa35dTHYx09Xp/wLBZP0j?= =?us-ascii?Q?xn77qEPirHNvRVUbmT20t03gh3uicUb695AAmld80AgW7tZVirCDOMNfo9Eo?= =?us-ascii?Q?gzou6FwFHs+BE75gpXmf+1Wz8TXn8sANlSgxaDLO7JefMoaVOBAqagRRsesR?= =?us-ascii?Q?HJMfqMVbqIIJBNbrYW4JjdggfdWOQfFiYZHU8rIKwEV4xOREdQnyqNqoCJcB?= =?us-ascii?Q?u5qWBaPwsi1I7uP5Zu0mehbFLGRbgcZuUrEi326C7X/AFgZ7FIY19hdtaFNt?= =?us-ascii?Q?8kLIcANDKVzTaVMnd4kREqS9tU2vh5ObW+Xj/9d9yuIzJ9ZujbsmyoPqXOVa?= =?us-ascii?Q?/FKCl302l1AKxioF4fsoviZ88T7i7Dee0iot7CS?= X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 6:gcbNLIm/H4vuLwaQW53JOYCCK63DBZgUZm1cMsy6nP2g6IqMWgEZ6W71+5y5kyu4VvPeEgKwBG9vxHAlCE1XN3Is2HCQVkWMBEha0Un6UOhTZRdol8Q1nFvU2maRVHRjf4Btt0dURslE7e1YtluHR4h1mu97d43ucKGAk3whpPfUWdVSdlCfrfRNdHxdvE4ELPm0HUOtUVXkUIkQvrtX+W5S8bIHNPCgx+0HhYQfAKAyZZyEStRMpSAYEEkJzPHyRqhU2dsYSs2x/Uu3swEWO98ZaG5ApUtgS643wXJVahk+Fr5jTMcePk+mol5pI21fOp9NEAUZLXhMEDk+ePkYzQ==; 5:2HtMIIGqJkPlgZSOK1tJyj7oUZTIfz6bMDItJnygiIv6qUF4KD0wSi/DYt7SqyXWzGnirdgLWvA7XFMwZE0x5wg/sgs5S1ZFW+nUjShvkC1Mw8ws81MpfvQrsTSnjVZeIIrEy27nZ7AtzxOTrz8waA==; 24:PnY6xCdMhqr7zGtZlrAzkw5THvIzGg95wvxXhd5pf1/Ls7wN/Yvqxr7LlUY1zkp8sdUIzjgtvSRrlpVlXEnzg9zUSRaILQuUA/OsofbPURM=; 7:B3bD5an+VagrqR+a6pAIOQmPh//MXg+d/kurdhxGg4wSbNKhK2pVHSmcfWOPBX6iKNQjmCmI0jP7AsXUoBM1Yu70hSGR6mOKLfrIhyPN42m1V1e+8rLK3cojyiKil+10BOwCRerxemZ25YXCiDncnM/HRk9BSXN0J+tKn3guh66mJ7ZnT27PbgYNCogQC7bWOI5m1K/KZtd6jyxIn/q49i8gRCuaDFGf+9NFLKCDaHE= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2017 12:45:47.1056 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: BN6PR07MB3089 Subject: [dpdk-dev] [PATCH v2 11/26] net/octeontx: add eth device probe and remove 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: Sun, 08 Oct 2017 12:45:51 -0000 From: Jerin Jacob An octeontx ethdev device consists of multiple PKO VF devices, a PKI VF device and multiple SSOVF devices which shared between eventdev. This patch adds a vdev based device called "eth_octeontx" which will create multiple ethernet ports based on "nr_port" or maximum physical ports are available in the system. Signed-off-by: Jerin Jacob Co-authored-by: Santosh Shukla Signed-off-by: Santosh Shukla --- drivers/net/octeontx/Makefile | 1 + drivers/net/octeontx/octeontx_ethdev.c | 321 +++++++++++++++++++++++++++++++++ drivers/net/octeontx/octeontx_ethdev.h | 94 ++++++++++ 3 files changed, 416 insertions(+) create mode 100644 drivers/net/octeontx/octeontx_ethdev.c create mode 100644 drivers/net/octeontx/octeontx_ethdev.h diff --git a/drivers/net/octeontx/Makefile b/drivers/net/octeontx/Makefile index 65de34c87..e0eaf059c 100644 --- a/drivers/net/octeontx/Makefile +++ b/drivers/net/octeontx/Makefile @@ -53,6 +53,7 @@ VPATH += $(SRCDIR)/base SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_pkovf.c SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_pkivf.c SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_bgx.c +SRCS-$(CONFIG_RTE_LIBRTE_OCTEONTX_PMD) += octeontx_ethdev.c LDLIBS += -lrte_eventdev LDLIBS += -lrte_pmd_octeontx_ssovf diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c new file mode 100644 index 000000000..621035233 --- /dev/null +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -0,0 +1,321 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium Inc. 2017. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#include +#include +#include +#include +#include +#include + +#include +#include +#include +#include +#include +#include +#include +#include +#include + +#include "octeontx_ethdev.h" +#include "octeontx_logs.h" + +struct octeontx_vdev_init_params { + uint8_t nr_port; +}; + +/* Parse integer from integer argument */ +static int +parse_integer_arg(const char *key __rte_unused, + const char *value, void *extra_args) +{ + int *i = (int *)extra_args; + + *i = atoi(value); + if (*i < 0) { + octeontx_log_err("argument has to be positive."); + return -1; + } + + return 0; +} + +static int +octeontx_parse_vdev_init_params(struct octeontx_vdev_init_params *params, + struct rte_vdev_device *dev) +{ + struct rte_kvargs *kvlist = NULL; + int ret = 0; + + static const char * const octeontx_vdev_valid_params[] = { + OCTEONTX_VDEV_NR_PORT_ARG, + NULL + }; + + const char *input_args = rte_vdev_device_args(dev); + if (params == NULL) + return -EINVAL; + + + if (input_args) { + kvlist = rte_kvargs_parse(input_args, + octeontx_vdev_valid_params); + if (kvlist == NULL) + return -1; + + ret = rte_kvargs_process(kvlist, + OCTEONTX_VDEV_NR_PORT_ARG, + &parse_integer_arg, + ¶ms->nr_port); + if (ret < 0) + goto free_kvlist; + } + +free_kvlist: + rte_kvargs_free(kvlist); + return ret; +} + +static inline void +devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf, + struct rte_event_dev_info *info) +{ + memset(dev_conf, 0, sizeof(struct rte_event_dev_config)); + dev_conf->dequeue_timeout_ns = info->min_dequeue_timeout_ns; + + dev_conf->nb_event_ports = info->max_event_ports; + dev_conf->nb_event_queues = info->max_event_queues; + + dev_conf->nb_event_queue_flows = info->max_event_queue_flows; + dev_conf->nb_event_port_dequeue_depth = + info->max_event_port_dequeue_depth; + dev_conf->nb_event_port_enqueue_depth = + info->max_event_port_enqueue_depth; + dev_conf->nb_event_port_enqueue_depth = + info->max_event_port_enqueue_depth; + dev_conf->nb_events_limit = + info->max_num_events; +} + +/* Create Ethdev interface per BGX LMAC ports */ +static int +octeontx_create(struct rte_vdev_device *dev, int port, uint8_t evdev, + int socket_id) +{ + RTE_SET_USED(dev); + RTE_SET_USED(port); + RTE_SET_USED(evdev); + RTE_SET_USED(socket_id); + + return -ENODEV; +} + +/* Un initialize octeontx device */ +static int +octeontx_remove(struct rte_vdev_device *dev) +{ + char octtx_name[OCTEONTX_MAX_NAME_LEN]; + struct rte_eth_dev *eth_dev = NULL; + struct octeontx_nic *nic = NULL; + int i; + + if (dev == NULL) + return -EINVAL; + + for (i = 0; i < OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT; i++) { + sprintf(octtx_name, "eth_octeontx_%d", i); + + /* reserve an ethdev entry */ + eth_dev = rte_eth_dev_allocated(octtx_name); + if (eth_dev == NULL) + return -ENODEV; + + nic = octeontx_pmd_priv(eth_dev); + rte_event_dev_stop(nic->evdev); + PMD_INIT_LOG(INFO, "Closing octeontx device %s", octtx_name); + + rte_free(eth_dev->data->mac_addrs); + rte_free(eth_dev->data->dev_private); + rte_free(eth_dev->data); + rte_eth_dev_release_port(eth_dev); + rte_event_dev_close(nic->evdev); + } + + /* Free FC resource */ + octeontx_pko_fc_free(); + + return 0; +} + +/* Initialize octeontx device */ +static int +octeontx_probe(struct rte_vdev_device *dev) +{ + const char *dev_name; + static int probe_once; + uint8_t socket_id, qlist; + int tx_vfcnt, port_id, evdev, qnum, pnum, res, i; + struct rte_event_dev_config dev_conf; + const char *eventdev_name = "event_octeontx"; + struct rte_event_dev_info info; + + struct octeontx_vdev_init_params init_params = { + OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT + }; + + dev_name = rte_vdev_device_name(dev); + res = octeontx_parse_vdev_init_params(&init_params, dev); + if (res < 0) + return -EINVAL; + + if (init_params.nr_port > OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT) { + octeontx_log_err("nr_port (%d) > max (%d)", init_params.nr_port, + OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT); + return -ENOTSUP; + } + + PMD_INIT_LOG(DEBUG, "initializing %s pmd", dev_name); + + socket_id = rte_socket_id(); + + tx_vfcnt = octeontx_pko_vf_count(); + + if (tx_vfcnt < init_params.nr_port) { + octeontx_log_err("not enough PKO (%d) for port number (%d)", + tx_vfcnt, init_params.nr_port); + return -EINVAL; + } + evdev = rte_event_dev_get_dev_id(eventdev_name); + if (evdev < 0) { + octeontx_log_err("eventdev %s not found", eventdev_name); + return -ENODEV; + } + + res = rte_event_dev_info_get(evdev, &info); + if (res < 0) { + octeontx_log_err("failed to eventdev info %d", res); + return -EINVAL; + } + + PMD_INIT_LOG(DEBUG, "max_queue %d max_port %d", + info.max_event_queues, info.max_event_ports); + + if (octeontx_pko_init_fc(tx_vfcnt)) + return -ENOMEM; + + devconf_set_default_sane_values(&dev_conf, &info); + res = rte_event_dev_configure(evdev, &dev_conf); + if (res < 0) + goto parse_error; + + qnum = rte_event_queue_count(evdev); + pnum = rte_event_port_count(evdev); + if (pnum < qnum) { + octeontx_log_err("too few event ports (%d) for event_q(%d)", + pnum, qnum); + res = -EINVAL; + goto parse_error; + } + if (pnum > qnum) { + /* + * We don't poll on event ports + * that do not have any queues assigned. + */ + pnum = qnum; + PMD_INIT_LOG(INFO, + "reducing number of active event ports to %d", pnum); + } + for (i = 0; i < qnum; i++) { + res = rte_event_queue_setup(evdev, i, NULL); + if (res < 0) { + octeontx_log_err("failed to setup event_q(%d): res %d", + i, res); + goto parse_error; + } + } + + for (i = 0; i < pnum; i++) { + res = rte_event_port_setup(evdev, i, NULL); + if (res < 0) { + res = -ENODEV; + octeontx_log_err("failed to setup ev port(%d) res=%d", + i, res); + goto parse_error; + } + /* Link one queue to one event port */ + qlist = i; + res = rte_event_port_link(evdev, i, &qlist, NULL, 1); + if (res < 0) { + res = -ENODEV; + octeontx_log_err("failed to link port (%d): res=%d", + i, res); + goto parse_error; + } + } + + /* Create ethdev interface */ + for (i = 0; i < init_params.nr_port; i++) { + port_id = octeontx_create(dev, i, evdev, socket_id); + if (port_id < 0) { + octeontx_log_err("failed to create device %s", + dev_name); + res = -ENODEV; + goto parse_error; + } + + PMD_INIT_LOG(INFO, "created ethdev %s for port %d", dev_name, + port_id); + } + + if (probe_once) { + octeontx_log_err("interface %s not supported", dev_name); + octeontx_remove(dev); + res = -ENOTSUP; + goto parse_error; + } + probe_once = 1; + + return 0; + +parse_error: + octeontx_pko_fc_free(); + return res; +} + +static struct rte_vdev_driver octeontx_pmd_drv = { + .probe = octeontx_probe, + .remove = octeontx_remove, +}; + +RTE_PMD_REGISTER_VDEV(OCTEONTX_PMD, octeontx_pmd_drv); +RTE_PMD_REGISTER_ALIAS(OCTEONTX_PMD, eth_octeontx); +RTE_PMD_REGISTER_PARAM_STRING(OCTEONTX_PMD, "nr_port= "); diff --git a/drivers/net/octeontx/octeontx_ethdev.h b/drivers/net/octeontx/octeontx_ethdev.h new file mode 100644 index 000000000..4c880f187 --- /dev/null +++ b/drivers/net/octeontx/octeontx_ethdev.h @@ -0,0 +1,94 @@ +/* + * BSD LICENSE + * + * Copyright (C) Cavium Inc. 2017. All rights reserved. + * + * Redistribution and use in source and binary forms, with or without + * modification, are permitted provided that the following conditions + * are met: + * + * * Redistributions of source code must retain the above copyright + * notice, this list of conditions and the following disclaimer. + * * Redistributions in binary form must reproduce the above copyright + * notice, this list of conditions and the following disclaimer in + * the documentation and/or other materials provided with the + * distribution. + * * Neither the name of Cavium networks nor the names of its + * contributors may be used to endorse or promote products derived + * from this software without specific prior written permission. + * + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT + * OWNER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. + */ +#ifndef __OCTEONTX_ETHDEV_H__ +#define __OCTEONTX_ETHDEV_H__ + +#include + +#include +#include +#include +#include +#include + +#include + +#include "base/octeontx_bgx.h" +#include "base/octeontx_pki_var.h" +#include "base/octeontx_pkivf.h" +#include "base/octeontx_pkovf.h" +#include "base/octeontx_io.h" + +#define OCTEONTX_VDEV_DEFAULT_MAX_NR_PORT 12 +#define OCTEONTX_VDEV_NR_PORT_ARG ("nr_port") +#define OCTEONTX_MAX_NAME_LEN 32 + +static inline struct octeontx_nic * +octeontx_pmd_priv(struct rte_eth_dev *dev) +{ + return dev->data->dev_private; +} + +/* Octeontx ethdev nic */ +struct octeontx_nic { + struct rte_eth_dev *dev; + int node; + int port_id; + int port_ena; + int base_ichan; + int num_ichans; + int base_ochan; + int num_ochans; + uint8_t evdev; + uint8_t bpen; + uint8_t fcs_strip; + uint8_t bcast_mode; + uint8_t mcast_mode; + uint16_t num_tx_queues; + uint64_t hwcap; + uint8_t link_up; + uint8_t duplex; + uint8_t speed; + uint16_t mtu; + uint8_t mac_addr[ETHER_ADDR_LEN]; + /* Rx port parameters */ + struct { + bool classifier_enable; + bool hash_enable; + bool initialized; + } pki; + + uint16_t ev_queues; + uint16_t ev_ports; +} __rte_cache_aligned; + +#endif /* __OCTEONTX_ETHDEV_H__ */ -- 2.14.1