From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0060.outbound.protection.outlook.com [104.47.36.60]) by dpdk.org (Postfix) with ESMTP id 296901B1F5 for ; Sun, 8 Oct 2017 14:45:52 +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=gA5eXxChKL6quN+/mjtrp1Bj/uFgZNpT0BTolRNEA8U=; b=UfSpZyUZ8ACLCf9riMwnfp3QalrC5ashmGcurN3accFaL1m/tbk0xoK68D3JDmJA1AtnhrEiL2e4CVgSPCHSY3/mo5dxL1TDGTO5X8LQahYv9/mdIrZqd8Ra3aKSFLAaP8gr0biC/GBfoQkKJlCNv2YC5wMMnV7bZF6rWU1fpRw= 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:49 +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:16 +0530 Message-Id: <20171008124430.1866-13-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: 2f488f14-965e-4c3e-7938-08d50e4a8235 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(22001)(2017030254152)(2017052603199)(201703131423075)(201703031133081)(201702281549075); SRVR:BN6PR07MB3089; X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 3:feizo86e3ueXHPlkwUC4yUW2Fwl+enbP7lAVoPdlKata/IihUg2ryyl1EHzXHmshl8icGLGGWNYVm/NWz3zhBzW/61MJsZNq1KOa8tz+nVBGmBbFBpQwmEf/o0xGmUKv6xaI/9BnKkxfaGFEkZzDTUjCbQvODbMudC/kLkqjKHxmAPJzdsauChQTeMJ/r3jISKo+gv3guH1WYXCc3bqhBgE1FtwzXk9bGcIakPZYuwk9Kh6aYZxMwJS+QD0OltF4; 25:jW8cOPTdHp6yWA16blYyFMnAEiHdwOL2gj85Iool8l7bPT5Os1/AZ84EOC9n77fi972gSSPgCGsBM2zyY4Qa8WLsfLamaPmUaxWSNmPOGNVLJJXRiK280vdrKQGWswg3Hupz2LgEnnUrQzJwYo8gdUfaI+gR1vCz3DjcY54bT8slMoR8+cWbEWjymwnSwP3uuRQmWZ1k0ayis1XNJKBIa2i/PpUpuhbq/zoMLbbH/yihph77/3E6F1+DxDhJoMKa6XTM98hg5c/VgzmqvO5dcNqY+MgtbyFB2QXvqQV/eIb1EulqWfDEUo4QltPaWLHeOsWuvqxLlH+uq0Gmz530/w==; 31:XDa8KmkT6W51Yfm8fMxIIFZdpR+nbBhBOE9dPcxYN0Bnu3KmW4FPVNAWpFPOCgIFL+ugkR3I772cfYkOBShJ+DrLOQaK2W+Il4BeNS1AXx/gPxuk/F0KOn220uzIrqqGXucQZnKiQftkg8buzxdWeVnJWw9Ses6MXU47qV8DPpd8Ek/lBIZw8o3dI/kZE4MqIInlGlH2y0kM0gZWgWEix3TRvBttIbS7CotZXiQqu2A= X-MS-TrafficTypeDiagnostic: BN6PR07MB3089: X-Microsoft-Exchange-Diagnostics: 1; BN6PR07MB3089; 20:SZ3GeeZcp05S2oI6oaLJpVIxVKbg8u0qjPfCEvrevpmuQcmdEW55032EBRg4kFjR7yV6c87Qaj/kMJGsSOA/pme1/RG92M1nr5IJHuzBIAsnyged3EGgkciCuCEQdZtPSZl9wz01xvZm3bwU3CGBO9Kp37m/UAjc0jR6mtKFReXtUeHflERiAOhPuD+tbO2VxB8XdivmjNaubuLL/qLWqU7RT08FmniHLCJyegV5HyLpejZMLkXDIwR6sFXe+VE2VXrwaFsni5bmacakk05anl376kHs34Uc8dtDX1wtQK18TRig7MiGJcsWcuXW/YTyldOzeOXIMz9lTEL/1dTVv4B7AcPm7nOmrrNOdAYdotm30ac6myUE3KtKQOivJSjEmUJcAMjCYYsQUAFF1SNCdCy8sPOaXQft1UIb89zECHOdjgRjbH1pcjJ2PAh7+HPv6kb1RlpnZF9KNiJhKNxe3AKj1xnA4P2h7ATL/BdBaTUuLvN0GhxRjwg5fP5nmFVbq8k2MqdF5EjGb2XJOEchSrT86bU1maYDQZa7527qMJ4NhAxq2nRV+VpmpQPrHQ6kzh/iCIAfQl5jqt3kbQTP9mEJzHNXOupexNUkano7mNQ=; 4:evXzAZsGD1awNrZIZqx4pbI1zmIituptikRI4ze5Ak+ax2gRqPK6tPng4l2EBHQ2zssd4c0Pk1pde+FbptEolXwfwpkAKGfj4gpuN7NTU+3wxXqUS9Rid3TpugKxfvGyefu6cj75rrSXcacZZROUIwwEMlXeYyX/W2RBN+oa2pqT9rDnV8zOFD4uNkfoMcOmQcTuXuKtCq5EXSHmiXPAOGR5CunjIuB/BdCTQwH49C8OnrT95RCGt+lpZnNkpjsF 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)(5890100001)(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:j1YRxW+4eqjEc3cTtaKsi9u71BYOWCV2j9PpPhLjg?= =?us-ascii?Q?dUhfFrpyF5YCaG3Betj9ygFKQQsokpymI02B935RjRjcI3P0sFIIzOAXlOVd?= =?us-ascii?Q?VKmED5n+73BKb0NjO7okFY9+xwZypzd592VEadNkdeWPcvvQ5t043YUgDoSt?= =?us-ascii?Q?A3SP7FdjIquqOz5H3oa75rB61azzeRUhuidBCgTo9MTlYetWfC7lCtWffBNz?= =?us-ascii?Q?grfHKgP2KWp/ColgkUfPhGzETrj8THZrQ0crWl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NZ1yTBSSnTFjLbzZJC9aN/C4HcgvhgLp7AmkNMPXJ56NlPwrJi4= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 08 Oct 2017 12:45:49.7916 (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 12/26] net/octeontx: create ethdev ports 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:54 -0000 From: Jerin Jacob Create ethdev ports by registering withethdev subsystem based on "nr_port" vdev argument or maximum physical ports available in the system. Signed-off-by: Jerin Jacob Co-authored-by: Santosh Shukla Signed-off-by: Santosh Shukla --- drivers/net/octeontx/octeontx_ethdev.c | 172 ++++++++++++++++++++++++++++++++- 1 file changed, 167 insertions(+), 5 deletions(-) diff --git a/drivers/net/octeontx/octeontx_ethdev.c b/drivers/net/octeontx/octeontx_ethdev.c index 621035233..6a727a0f0 100644 --- a/drivers/net/octeontx/octeontx_ethdev.c +++ b/drivers/net/octeontx/octeontx_ethdev.c @@ -105,6 +105,50 @@ octeontx_parse_vdev_init_params(struct octeontx_vdev_init_params *params, return ret; } +static int +octeontx_port_open(struct octeontx_nic *nic) +{ + octeontx_mbox_bgx_port_conf_t bgx_port_conf; + int res; + + res = 0; + + PMD_INIT_FUNC_TRACE(); + + res = octeontx_bgx_port_open(nic->port_id, &bgx_port_conf); + if (res < 0) { + octeontx_log_err("failed to open port %d", res); + return res; + } + + nic->node = bgx_port_conf.node; + nic->port_ena = bgx_port_conf.enable; + nic->base_ichan = bgx_port_conf.base_chan; + nic->base_ochan = bgx_port_conf.base_chan; + nic->num_ichans = bgx_port_conf.num_chans; + nic->num_ochans = bgx_port_conf.num_chans; + nic->mtu = bgx_port_conf.mtu; + nic->bpen = bgx_port_conf.bpen; + nic->fcs_strip = bgx_port_conf.fcs_strip; + nic->bcast_mode = bgx_port_conf.bcast_mode; + nic->mcast_mode = bgx_port_conf.mcast_mode; + nic->speed = bgx_port_conf.mode; + + memcpy(&nic->mac_addr[0], &bgx_port_conf.macaddr[0], ETHER_ADDR_LEN); + + octeontx_log_dbg("port opened %d", nic->port_id); + return res; +} + +static void +octeontx_port_close(struct octeontx_nic *nic) +{ + PMD_INIT_FUNC_TRACE(); + + octeontx_bgx_port_close(nic->port_id); + octeontx_log_dbg("port closed %d", nic->port_id); +} + static inline void devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf, struct rte_event_dev_info *info) @@ -126,17 +170,135 @@ devconf_set_default_sane_values(struct rte_event_dev_config *dev_conf, info->max_num_events; } +/* Initialize and register driver with DPDK Application */ +static const struct eth_dev_ops octeontx_dev_ops = { +}; + /* 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); + int res; + char octtx_name[OCTEONTX_MAX_NAME_LEN]; + struct octeontx_nic *nic = NULL; + struct rte_eth_dev *eth_dev = NULL; + struct rte_eth_dev_data *data = NULL; + const char *name = rte_vdev_device_name(dev); - return -ENODEV; + PMD_INIT_FUNC_TRACE(); + + sprintf(octtx_name, "%s_%d", name, port); + if (rte_eal_process_type() != RTE_PROC_PRIMARY) { + eth_dev = rte_eth_dev_attach_secondary(octtx_name); + if (eth_dev == NULL) + return -ENODEV; + + return 0; + } + + data = rte_zmalloc_socket(octtx_name, sizeof(*data), 0, socket_id); + if (data == NULL) { + octeontx_log_err("failed to allocate devdata"); + res = -ENOMEM; + goto err; + } + + nic = rte_zmalloc_socket(octtx_name, sizeof(*nic), 0, socket_id); + if (nic == NULL) { + octeontx_log_err("failed to allocate nic structure"); + res = -ENOMEM; + goto err; + } + + nic->port_id = port; + nic->evdev = evdev; + + res = octeontx_port_open(nic); + if (res < 0) + goto err; + + /* Rx side port configuration */ + res = octeontx_pki_port_open(port); + if (res != 0) { + octeontx_log_err("failed to open PKI port %d", port); + res = -ENODEV; + goto err; + } + + /* Reserve an ethdev entry */ + eth_dev = rte_eth_dev_allocate(octtx_name); + if (eth_dev == NULL) { + octeontx_log_err("failed to allocate rte_eth_dev"); + res = -ENOMEM; + goto err; + } + + eth_dev->device = &dev->device; + eth_dev->intr_handle = NULL; + eth_dev->data->kdrv = RTE_KDRV_NONE; + eth_dev->data->numa_node = dev->device.numa_node; + + rte_memcpy(data, (eth_dev)->data, sizeof(*data)); + data->dev_private = nic; + + data->port_id = eth_dev->data->port_id; + snprintf(data->name, sizeof(data->name), "%s", eth_dev->data->name); + + nic->ev_queues = 1; + nic->ev_ports = 1; + + data->dev_link.link_status = ETH_LINK_DOWN; + data->dev_started = 0; + data->promiscuous = 0; + data->all_multicast = 0; + data->scattered_rx = 0; + + data->mac_addrs = rte_zmalloc_socket(octtx_name, ETHER_ADDR_LEN, 0, + socket_id); + if (data->mac_addrs == NULL) { + octeontx_log_err("failed to allocate memory for mac_addrs"); + res = -ENOMEM; + goto err; + } + + eth_dev->data = data; + eth_dev->dev_ops = &octeontx_dev_ops; + + /* Finally save ethdev pointer to the NIC structure */ + nic->dev = eth_dev; + + if (nic->port_id != data->port_id) { + octeontx_log_err("eth_dev->port_id (%d) is diff to orig (%d)", + data->port_id, nic->port_id); + res = -EINVAL; + goto err; + } + + /* Update port_id mac to eth_dev */ + memcpy(data->mac_addrs, nic->mac_addr, ETHER_ADDR_LEN); + + PMD_INIT_LOG(DEBUG, "ethdev info: "); + PMD_INIT_LOG(DEBUG, "port %d, port_ena %d ochan %d num_ochan %d tx_q %d", + nic->port_id, nic->port_ena, + nic->base_ochan, nic->num_ochans, + nic->num_tx_queues); + PMD_INIT_LOG(DEBUG, "speed %d mtu %d", nic->speed, nic->mtu); + + return data->port_id; + +err: + if (port) + octeontx_port_close(nic); + + if (eth_dev != NULL) { + rte_free(eth_dev->data->mac_addrs); + rte_free(data); + rte_free(nic); + rte_eth_dev_release_port(eth_dev); + } + + return res; } /* Un initialize octeontx device */ -- 2.14.1