From mboxrd@z Thu Jan 1 00:00:00 1970 Return-Path: Received: from NAM02-SN1-obe.outbound.protection.outlook.com (mail-sn1nam02on0046.outbound.protection.outlook.com [104.47.36.46]) by dpdk.org (Postfix) with ESMTP id 4BD817D31 for ; Thu, 31 Aug 2017 16:55:49 +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=COtKyuJfPckZ8TPEaxyuokGkK9FKh50c+6k8/OlIX+E=; b=QrAzrx7GcLyYietrm6GiWiEuF3uyG6+bU1wwT0HIFql2A7EoBM8gTlCpO7g22GqdFWypd5OUoGSX+Curvmye4ClMSn/19sRj8MQ1di83uxReisOID7Tpn+IGsPV+9WliAgAYsZYmFzTy+cpjTu1VTu+y84rbx5gNVCbdPL9Zobg= Authentication-Results: spf=none (sender IP is ) smtp.mailfrom=Jerin.JacobKollanukkaran@cavium.com; Received: from jerin.domain.name (171.76.126.71) by SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_CBC_SHA384_P256) id 15.20.13.10; Thu, 31 Aug 2017 14:55:46 +0000 From: Jerin Jacob To: dev@dpdk.org Cc: ferruh.yigit@intel.com, santosh.shukla@caviumnetworks.com, Jerin Jacob Date: Thu, 31 Aug 2017 20:24:22 +0530 Message-Id: <20170831145436.5397-13-jerin.jacob@caviumnetworks.com> X-Mailer: git-send-email 2.14.1 In-Reply-To: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> References: <20170831145436.5397-1-jerin.jacob@caviumnetworks.com> MIME-Version: 1.0 Content-Type: text/plain X-Originating-IP: [171.76.126.71] X-ClientProxiedBy: MA1PR01CA0109.INDPRD01.PROD.OUTLOOK.COM (2603:1096:a00:1::25) To SN2PR07MB2526.namprd07.prod.outlook.com (2603:10b6:804:6::26) X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 6e8af18e-893a-4877-ddbb-08d4f0805d66 X-Microsoft-Antispam: UriScan:; BCL:0; PCL:0; RULEID:(300000500095)(300135000095)(300000501095)(300135300095)(300000502095)(300135100095)(22001)(2017030254152)(300000503095)(300135400095)(2017052603199)(201703131423075)(201703031133081)(201702281549075)(300000504095)(300135200095)(300000505095)(300135600095)(300000506095)(300135500095); SRVR:SN2PR07MB2526; X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 3:xMnDtso8yDe1CY9qI4oOwMfqaj8guKz3Pjg38VBcFnZuG7M1Q7VQ7yksFO/Ww2lOniWZFCmJ0ChPQwZIttvazkbYinv2kftfnLsDk4JBRnDeBSN8D6WoKl/QGT8YXo8XStQkFBY0+wZFbAKnmBKvQvYzXOQdyDesUu6I/fzxNVIZQFHFG8VWEUUq7k06NPm1hUkWLVZ6BZla80f2VfswXwuYhVsWKICkiJKmIF6Vx30pyq3Cx6twpRqOill0Oh+5; 25:z6uEuckVRhhYlzBkrpH0wapItNMIS1vjpVlw552T8rwyGnOb7a23dBdqaXCJTTlxVV8FIfJUeePV5djiYEXI7DJb5cKGzsghvRxaaaJKM6NfmHMWgv7aKvN8FhVCNhn+7TgvN8/j5FF6OGCSygfBqUNOBnDb7eliZd5eSB3t4Fl8KufqszrpDHfjYtjigtGJxXVwJkNtT7uJPCzOll8159cOTNDnhz+XXD/P5j8FnUStZeKjFTI9tahGbi3ATvbvWltLRBxat7SBGbg7+HfoBlpoBw9XMcFxPIrW1BekMl/DxIkTTf0dCwUhOe3jvgiYXJXM0dzCYX899ydunwZtHg==; 31:FWpnVqJrkKIygoxRwSglKPdqAXqqi6/1jkAG6qELRjx7SpVe1UZ9W8IELyY2DXBI2SS+Ha2gnGz8Y3KUJyffOa3QD2jW1V5GmKVG1VzI9kRN1WqQEOSddfcQaVGUxy1Arxj0mc5EfkkUUV+8VhDoKpPQNcljMjdIQh4anl5Te2CiCT4Rz0CCjmlfFbgkloX0VKPov77NH5FS1HuClzIMkt9qp+x3rRqx+BbL+olQ3FI= X-MS-TrafficTypeDiagnostic: SN2PR07MB2526: X-Microsoft-Exchange-Diagnostics: 1; SN2PR07MB2526; 20:o6kSaN3ul/5RN+gT1wD97ceWo8FMiuqxvTbxZFxoZ8E0i5X57TTgCsqYuob+YeD0IbHZ7zq2u5cDfjbYx6yj8UqWprd3u6MOII2HQnUOZzmebeFA6VdGCXI2T5dSufRcMdQRVS0SK2fJge5maKdKBuRtt7//qQn2A7tKKWHiT/rm58D9g8LTd9HxaF+OFme0WOoccL7AxYSW4LoA+1ZS5ArWLArGOSx8M87k35pb8gbhvIoLXKdEX3C60363KX9gd9UFOEdmjzsbjEyN9DwMem+HjuoRyWJ8LNjVJ8Jye/0Ap75yvmaJVhZBn63r5CMqoMDC/YBiw0TtUVPDEOyhGNXiTER1hfs5GwR8wCBc4UFj2lNL3o09wPhEr0uYpcCXXKRgnAZklD6mHIek/T6nQwrbLmhtgfW+jX44a/9jdPa74nbDLgeRmZp0PkZQrFvdoYlMJvIcTInNW+7ByOjRqH7NUK/2OfKuakGjX8yqmQNvsjuHcPcdrpgfJ+syGQChhmz+zJDFxypczxObhD3tSQS7CFE3/l/yjZaS0GW81UMMKAxFS2DMOIBJRIl6strV5TUkoGwhaGppraYqegb0RJuuVPKVTcxbZO2VLpxv4GM=; 4:50BvcaYN0D+PvAUorY7sbnULyaDjsuHXB9sh3aQn7WaKvor2Om3QyCuEweMs6HX1ZkcG1HleYgtUwsXRwi/CM2iBOWDdhSgfoSsZLEGTv8RwXnn0hbqKqprObUVaK1uW9X0h1+E6YzRDjdKRWMgtKJTZUIkbrdhi06hE9eQgYO7sRScAIw/FiU92ZKEOfKjFB5/kz/4KVGO7jgGDuF5BGtZk+i+U1uCSv2eOkxv6X1o38hHnPgSht3/ZnwhvUWjH 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)(601004)(2401047)(5005006)(8121501046)(93006095)(100000703101)(100105400095)(10201501046)(3002001)(6041248)(201703131423075)(201702281528075)(201703061421075)(201703061406153)(20161123558100)(20161123564025)(20161123562025)(20161123560025)(20161123555025)(6072148)(201708071742011)(100000704101)(100105200095)(100000705101)(100105500095); SRVR:SN2PR07MB2526; BCL:0; PCL:0; RULEID:(100000800101)(100110000095)(100000801101)(100110300095)(100000802101)(100110100095)(100000803101)(100110400095)(100000804101)(100110200095)(100000805101)(100110500095); SRVR:SN2PR07MB2526; X-Forefront-PRVS: 04163EF38A X-Forefront-Antispam-Report: SFV:NSPM; SFS:(10009020)(6009001)(199003)(189002)(25786009)(1076002)(53936002)(5890100001)(3846002)(6116002)(575784001)(478600001)(110136004)(72206003)(7736002)(6666003)(107886003)(6512007)(305945005)(6506006)(36756003)(6486002)(68736007)(5003940100001)(189998001)(50986999)(42882006)(106356001)(101416001)(76176999)(2950100002)(6916009)(5660300001)(2361001)(33646002)(2351001)(2906002)(4326008)(97736004)(105586002)(48376002)(50466002)(81166006)(66066001)(69596002)(8936002)(47776003)(53416004)(8676002)(50226002)(81156014)(42186005); DIR:OUT; SFP:1101; SCL:1; SRVR:SN2PR07MB2526; H:jerin.domain.name; 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; SN2PR07MB2526; 23:qsJyBd6w4tMtz92GIhCwy7HNLuhx93bxB14JxvaLR?= =?us-ascii?Q?RkGqRAgkBMiAHCCy7hyYbnCcUt0zYey7euidNSpU9dYRvTeY4DvnBSK2zgCJ?= =?us-ascii?Q?rtB7Fc/iZhVjXtxxCsxGpVv/UhhozY/j7clrQOBAw8KmJUog7Isa2bJN74Ts?= =?us-ascii?Q?5PTtBUng9RLLiEVQ/vQaR33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b8E7ko0= SpamDiagnosticOutput: 1:99 SpamDiagnosticMetadata: NSPM X-OriginatorOrg: caviumnetworks.com X-MS-Exchange-CrossTenant-OriginalArrivalTime: 31 Aug 2017 14:55:46.2085 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 711e4ccf-2e9b-4bcf-a551-4094005b6194 X-MS-Exchange-Transport-CrossTenantHeadersStamped: SN2PR07MB2526 Subject: [dpdk-dev] [PATCH 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: Thu, 31 Aug 2017 14:55:49 -0000 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 --- 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