From patchwork Mon Apr 25 03:44:21 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825238 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id B9C9CC433F5 for ; Mon, 25 Apr 2022 03:46:00 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240934AbiDYDs6 (ORCPT ); Sun, 24 Apr 2022 23:48:58 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41728 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240944AbiDYDsg (ORCPT ); Sun, 24 Apr 2022 23:48:36 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2073.outbound.protection.outlook.com [40.107.212.73]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6096125286 for ; Sun, 24 Apr 2022 20:45:32 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=et5+ZWvr2QaLB1Hsg67LlowsOhgwpLPSbTbWJrknJ87bRFgcKshzwLPNwN+QYMMFxmDbu1nrWCAFu5v3OMWOkABO4QEfnpKwWomjXfnqFJxjkme3yIudqiBwkehJb6poiBf4X1+vusqnRi/3aM1IhwEDFtmATsOL1bZtqWLbXW1Rnar9GsEx3Y0Me34iddHRS1gXLtvyLKy79acVZN2VsqkMsVPLFUIVbRZd8uqjYAqvUN4uXEn3KVFb5QAAxyVmrfPnTmeHNuhNQvKUkqC1rE61jF2YksSxSdn8Bva47aQaFbyRHergg1PSrE1F8A3wRx/Qnbfn92sS2sJBXVZVHw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kO5Urd5MUwOvpwNYX6h7+MgLUk8cVAj3yoE41WtjoxE=; b=ISahMlJoAyaKsgawSe3zChAbFkFk08JD2QAxcgpQ6WlB5EN5DdomA/SE803tT6sDGghjHuUP2xxu9GLTwF0RjfmF/5ISfOjRCfyJX3kijWQByCFpWR1EeYSzx9fD/GSy6eptT0FGpnWBKhlMrWQiUkHhwAj30gbm4ee8rT/WmSHJIIlo2wOii5ESADUBcTSEAY+omEpO+vg02Vg3WJcHixJuHafV3UEyxkvM0nvYDH0ri/iRFRwiSsi1UxJ1dZfdYD1CwQubgXYYiCZahOeXiecqpWxJz6RxRQMXUYG175iisuJdznvqBnRXaW15Ey3KP1QOlNmnNqCfWU2MQJIZaw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kO5Urd5MUwOvpwNYX6h7+MgLUk8cVAj3yoE41WtjoxE=; b=UceySjWJQIpyvTVxn0zoCofhkEPTAGEwjyqAJwVv9MLDfJl1yJsOygjRiR7n/RkqcZFOT6cxxys7ESZZi7wQ7kp9ZS4i/al1I3LpLIMiGZDIQ8/hD1Hv8Q7cjpCa5N2/bY4DWDC1NO+Yorit+P1sUr03e1NrnHCNZrDNbNfLfI2zAhVaVndlcoQpmmGkpL9iDQu9AojM9+pVhFL8vvWiNJhqRwlUCnTdVA1GMPrYdVAb747MH50z/PUSG2Pi1LjkIj8ePk7uF67NsZtdbkelWSYk7wyxZuKYxWKLWEPbu6zwmErsydFROVH31Q2ja+lI0wElMBn0BaG8U8q8+5j8Cg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MWHPR1201MB0255.namprd12.prod.outlook.com (2603:10b6:301:4f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Mon, 25 Apr 2022 03:45:30 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:45:30 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 01/11] devlink: introduce line card devices support Date: Mon, 25 Apr 2022 06:44:21 +0300 Message-Id: <20220425034431.3161260-2-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0102CA0068.eurprd01.prod.exchangelabs.com (2603:10a6:803::45) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 7e5ce86f-f315-4e9f-539b-08da266e0a45 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0255:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: c5BUO1xQl9K9aGTqZdKWPwtD66du0dFvFL68JwHsWAsn77OwmfDyt9eZZwXaYK9bQxrpypfwjbjDbHbRIv6RPTYPYXlQ56t7CsAqXL6hQdTwIPeXYtUDvKYzdM5ZDm2oIq2LI2vDqoGbOPl8Va04QLog6YElSSsvlHieLrFUkxeCkI4VEwrqGeyx+Vxwg5WUMseqLWOsC7u1nQDFtGw3Qs0wnH9eyyi2ax02vdYY0CqKa+ieKIjhur42bPMyF/xmoWwW6JQENlsnoyFTElxWHfPqoqGzdWDx2GoxyqW8oSlsMKGNhnN+01C9XmZykr1ZB1LJ604KrSJJQ8fRJTKrSZsF/NjJiv1O7ubv82Kew9iujFO7lb1NapUPCGK8dMjNATH9jlyEG908mfKjYHf/b35f8DQrmcMti+PqUAUr8DE7Zv1XIullv+nvt+OHythzAhaPrtWJ3KiGqlqY8tXwGhRIHYNSCog/fwcK2mpe/pQbtgaq8lZiMIAt49lEfTUwy3COsvbJ+R6BFjlzwv4aQoOAhUdXl1GA7XKI2qFRyZNyHfl2WsHSCh7XNofjEbvB8AfLCpGcmnV6piFqJ9fJeRIhh5xcEDax+bgrcouYhzIt83p0aqj27uxXbaxeLIhZv9zeKoi31gnNGD0pVLPFPA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(316002)(6486002)(508600001)(8676002)(66556008)(66476007)(86362001)(6916009)(38100700002)(66946007)(5660300002)(6666004)(6506007)(2906002)(36756003)(6512007)(83380400001)(26005)(186003)(8936002)(2616005)(1076003)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: jY6YiPx20NFNWuMl2KCE87AN2rcZvfbNppzMe1nDpYpnWJxAdbwhy7liW5c+mJ9M+2S+LKfm9+pk6kN3qnR5dETJrAPDktgjTQGeLQOQfVrQssysuZdeaTY9Z25a82h+WUpBMwTKpW76oilDy7iqobEe7oKk/NQkZ1SAxTw2tD0Z+sP1ASO4vW4NgJpqP764GT2J7+EE8N/P9CzteNss39bD9GSxTEIiBrH4hkXZfSqhuPdaTGv72SdvgiDE3kBO2tkIZcq96sLjhjulL2sAkgeF+TvnpS2O/VdEjXyTUhNjZ05GjsGOkaDS8gjDeP5ehvYSt1HtMhVPTB8Tzvna0DCX2McC2DyP7J69GNJVjEPnYMZKJRYSgKv4A6t4S2lZ4umDnwwJFKhcni0qfypm6BAsieaO3UbXbxl7SxNhf6oM3snQTc+6TDHi3JQXdtGeXeTgkjPkAuyYJ/+2zLponI7RWuExBCgmLQ4kjQOJYlsQoTZj8gHzPjDcwIPS5UgTWp43smjCJ8cyo9LE1NUO11Ozq9YQQzI/vWEybWj+iRe/Itct+QaOYXDCxpAGnagu6LMufq+evqI6zmh749W3n5kHQW/MF1Q7BGkgHBUrc4VtHERFPXxGehB4UhPpBhCLwE0X4G+hvVC1idjohE06vscH7+7zmTBKVNrWdVGiCqY97l9jIv2/DpKvmqylDz9GNxoy+Bxf2FMI7qI2yQ8/CQTaVpFndtyA9FF9R0MHtWecwKd3fs2vqpZAfU5GqpLTwrodAugavpdACg56D1qtZNQz56ARzIKl2jWCkcttY3uw+DzLDvgH/Qz0AiFZqiWgJ1wyBsbckWOAKT3q0VKtTa85WIqzCFwfD0s8uIAcJwNwvJE+sZp4Q97xBhieC5W4PgcqdSelZqZjwdxnLwdYziXISDZaOSBHzqIWRj8jM9GRggCZ3c2ZkbJ0O+UA5++972fVih9DxsgovIgCeWQyosJ0f/ZSonGchJVGX5LAhMMs3btcHH7Grw30D+em4SzYsNAoSws1kNNwwPULPu6Aw4YHCjS+uR9Gr2k2y92hZdbyAaA3FLSfEjrdmdIEE3YYPYVOUbnqTejUOgm5y+T6+LK2m1LweurU3v1r4Dq4X+6tEQqAFBmOBLa2s5TpA1nu6HIgzC1u82GHqgA/Qrd7mN/lZMCLhuBaBrt33sTRALf+thJZXmm7M15uCS2FPSsBSN35tO21B96pNG87bg4mH5mYenxpKWTk9IIxDHmVpp6riB4eEElY9MnflwbK4IFKRdPRaP0wNYOp0Nu/7YIiBkDSj84T8yDxUDndvBP9S2yxjSy57m0SzEfQjTKuvj3XBLuxqeJBzfVjqm1I20AJeP2vnAg0T1UE6fP6sYxHWh+/lWDTZ4wcy9EnS81iA79hX22AqRiItV97elZjWy4USr9W985ez4gx741KghuUTiuGM4Au5Bt38VEKb84r+dVbMb6XW1qcw39cCWwy2Af1CQfugJS6T5c3LbWZUcgkpuXB3KXP7vbCIH+1kUhv1R435Cf6gsgx1pqpwdeBrOGGf6XLIyYnz7XQ5+Zxw/u13OAKqPHQZWLbczp/V/9iFvP7oEFnr8UvZdKFl9lgJb5bgFBTnUdNXntKta+I/IItPOyoyPYvE3vWfaZxn802BTeuiuKQQtAUBS7yi67JLQ94+SZyic0niS2BjE/YtohJVGKwsTMhYs5XnvfLeCxhsEzrdBmy8JOmWmUbehx4P390Bw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 7e5ce86f-f315-4e9f-539b-08da266e0a45 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:45:30.3182 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: LEydoeOpX1n+RQzcBV6TWqPCPywtkSkliY4Ehwi5f3FpEXMuTWvhrhPd0QRTEUenB/a+SRRTLZHG91SMPE8PJg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0255 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Line card can contain one or more devices that makes sense to make visible to the user. For example, this can be a gearbox with flash memory, which could be updated. Provide the driver possibility to attach such devices to a line card and expose those to user. Example: $ devlink lc show pci/0000:01:00.0 lc 8 pci/0000:01:00.0: lc 8 state active type 16x100G supported_types: 16x100G devices: device 0 device 1 device 2 device 3 Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- include/net/devlink.h | 7 +++ include/uapi/linux/devlink.h | 3 + net/core/devlink.c | 104 ++++++++++++++++++++++++++++++++++- 3 files changed, 113 insertions(+), 1 deletion(-) diff --git a/include/net/devlink.h b/include/net/devlink.h index 2a2a2a0c93f7..c84b52fb9ff0 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -1578,6 +1578,13 @@ struct devlink_linecard * devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, const struct devlink_linecard_ops *ops, void *priv); void devlink_linecard_destroy(struct devlink_linecard *linecard); +struct devlink_linecard_device; +struct devlink_linecard_device * +devlink_linecard_device_create(struct devlink_linecard *linecard, + unsigned int device_index); +void +devlink_linecard_device_destroy(struct devlink_linecard *linecard, + struct devlink_linecard_device *linecard_device); void devlink_linecard_provision_set(struct devlink_linecard *linecard, const char *type); void devlink_linecard_provision_clear(struct devlink_linecard *linecard); diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index b3d40a5d72ff..cd578645f94f 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -575,6 +575,9 @@ enum devlink_attr { DEVLINK_ATTR_LINECARD_STATE, /* u8 */ DEVLINK_ATTR_LINECARD_TYPE, /* string */ DEVLINK_ATTR_LINECARD_SUPPORTED_TYPES, /* nested */ + DEVLINK_ATTR_LINECARD_DEVICE_LIST, /* nested */ + DEVLINK_ATTR_LINECARD_DEVICE, /* nested */ + DEVLINK_ATTR_LINECARD_DEVICE_INDEX, /* u32 */ /* add new attributes above here, update the policy in devlink.c */ diff --git a/net/core/devlink.c b/net/core/devlink.c index 5cc88490f18f..41d9631ceada 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -83,10 +83,11 @@ struct devlink_linecard { const struct devlink_linecard_ops *ops; void *priv; enum devlink_linecard_state state; - struct mutex state_lock; /* Protects state */ + struct mutex state_lock; /* Protects state and device_list */ const char *type; struct devlink_linecard_type *types; unsigned int types_count; + struct list_head device_list; }; /** @@ -2058,6 +2059,55 @@ struct devlink_linecard_type { const void *priv; }; +struct devlink_linecard_device { + struct list_head list; + unsigned int index; +}; + +static int +devlink_nl_linecard_device_fill(struct sk_buff *msg, + struct devlink_linecard_device *linecard_device) +{ + struct nlattr *attr; + + attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE); + if (!attr) + return -EMSGSIZE; + if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_DEVICE_INDEX, + linecard_device->index)) { + nla_nest_cancel(msg, attr); + return -EMSGSIZE; + } + nla_nest_end(msg, attr); + + return 0; +} + +static int devlink_nl_linecard_devices_fill(struct sk_buff *msg, + struct devlink_linecard *linecard) +{ + struct devlink_linecard_device *linecard_device; + struct nlattr *attr; + int err; + + if (list_empty(&linecard->device_list)) + return 0; + + attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_LIST); + if (!attr) + return -EMSGSIZE; + list_for_each_entry(linecard_device, &linecard->device_list, list) { + err = devlink_nl_linecard_device_fill(msg, linecard_device); + if (err) { + nla_nest_cancel(msg, attr); + return err; + } + } + nla_nest_end(msg, attr); + + return 0; +} + static int devlink_nl_linecard_fill(struct sk_buff *msg, struct devlink *devlink, struct devlink_linecard *linecard, @@ -2068,6 +2118,7 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg, struct devlink_linecard_type *linecard_type; struct nlattr *attr; void *hdr; + int err; int i; hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd); @@ -2100,6 +2151,10 @@ static int devlink_nl_linecard_fill(struct sk_buff *msg, nla_nest_end(msg, attr); } + err = devlink_nl_linecard_devices_fill(msg, linecard); + if (err) + goto nla_put_failure; + genlmsg_end(msg, hdr); return 0; @@ -10264,6 +10319,7 @@ devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, linecard->priv = priv; linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; mutex_init(&linecard->state_lock); + INIT_LIST_HEAD(&linecard->device_list); err = devlink_linecard_types_init(linecard); if (err) { @@ -10291,6 +10347,7 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard) struct devlink *devlink = linecard->devlink; devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_DEL); + WARN_ON(!list_empty(&linecard->device_list)); mutex_lock(&devlink->linecards_lock); list_del(&linecard->list); devlink_linecard_types_fini(linecard); @@ -10299,6 +10356,50 @@ void devlink_linecard_destroy(struct devlink_linecard *linecard) } EXPORT_SYMBOL_GPL(devlink_linecard_destroy); +/** + * devlink_linecard_device_create - Create a device on linecard + * + * @linecard: devlink linecard + * @device_index: index of the linecard device + * + * Return: Line card device structure or an ERR_PTR() encoded error code. + */ +struct devlink_linecard_device * +devlink_linecard_device_create(struct devlink_linecard *linecard, + unsigned int device_index) +{ + struct devlink_linecard_device *linecard_device; + + linecard_device = kzalloc(sizeof(*linecard_device), GFP_KERNEL); + if (!linecard_device) + return ERR_PTR(-ENOMEM); + linecard_device->index = device_index; + mutex_lock(&linecard->state_lock); + list_add_tail(&linecard_device->list, &linecard->device_list); + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); + mutex_unlock(&linecard->state_lock); + return linecard_device; +} +EXPORT_SYMBOL_GPL(devlink_linecard_device_create); + +/** + * devlink_linecard_device_destroy - Destroy device on linecard + * + * @linecard: devlink linecard + * @linecard_device: devlink linecard device + */ +void +devlink_linecard_device_destroy(struct devlink_linecard *linecard, + struct devlink_linecard_device *linecard_device) +{ + mutex_lock(&linecard->state_lock); + list_del(&linecard_device->list); + devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); + mutex_unlock(&linecard->state_lock); + kfree(linecard_device); +} +EXPORT_SYMBOL_GPL(devlink_linecard_device_destroy); + /** * devlink_linecard_provision_set - Set provisioning on linecard * @@ -10331,6 +10432,7 @@ EXPORT_SYMBOL_GPL(devlink_linecard_provision_set); void devlink_linecard_provision_clear(struct devlink_linecard *linecard) { mutex_lock(&linecard->state_lock); + WARN_ON(!list_empty(&linecard->device_list)); linecard->state = DEVLINK_LINECARD_STATE_UNPROVISIONED; linecard->type = NULL; devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); From patchwork Mon Apr 25 03:44:22 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825239 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 160C4C433EF for ; Mon, 25 Apr 2022 03:46:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240990AbiDYDtC (ORCPT ); Sun, 24 Apr 2022 23:49:02 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:41946 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240960AbiDYDsl (ORCPT ); Sun, 24 Apr 2022 23:48:41 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2083.outbound.protection.outlook.com [40.107.212.83]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 6F932237C9 for ; Sun, 24 Apr 2022 20:45:38 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=ZGLr5nMdgOlSbZLAL02EWLdW6r3+mlvrrd8c76b6zJMg+PDhgUDIfcu3BucDA9KYVYJipXAUl4j5aIfUuVLu9lDl4cUoOJUWteyyulhasfq08wB8TzcNLL3GmPgoIIvh7POyBOzwj/hOxQzVlcNHflox+gHbPGPSgoT/hfRLapzm6ORSNRVHKCVIdH6p+K/cV4fVvajUqnlKsRzDchL+BTDOoQTJmlXHuqA4jx5MyqeNENBVtw2JZAO45sfUEQaahLg+axcaS+lNYxtN3mLeqZkmzh8coQraG0GHaFxL/lVUGr7NcnPxCCs/qYC8pL4QE4jC5Jps+ENy148epX3ZSg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=M+gRZ+10ew3xWcyfm2EImPREj/Eu7LADHERqH0CdUXg=; b=Yl2aa7C+SvkVKv7GX7nLuozfQ2jnFtcmj6liMhUzirhZjUiodlUGW4CvSmZMYvV4m40eOL+UKE5C8y3J5PzndgZaOZUP+2Glqw03cGsUNTgu0gfonD3PDatO8iMaCrQVfiCm0RPUeqcf2rGX3SekChzd24r2LP5YlBc8ZOGg6C3rJ2Rhdh/rdXcxuD4ZkfxYIAblGEKjl4jiLUo5M1cSxuJ2+M+wthDJR3LRX1eJJSivZsedlGha5zD4tdtUJYzzxWcL8F+rcdf/2dyVWkLOpqipGBlYED6vNH+WrwjSybyWIfMz4zgGiSkHql74bfwmWGNaCwnZimQkw1YqNhohwQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=M+gRZ+10ew3xWcyfm2EImPREj/Eu7LADHERqH0CdUXg=; b=ZgBECQN+NrMnOErs7gepEQGkJ2Jxl27XezNxyWxPjWpdiig70lOHI0HIMpSb7gNZ2vtjqeXc+otUHnjARu2w0aHnxGPmUH7byDKYCV47sjTzDa4lYgruAyfhvW3haPbJpZdn6Kd5ank80pZovGUunrAf3BvfXjd/8bnhbLSEl1k4QVa/LgJSDdZ39VGbpmwVGoXBi3ptvufFOCkFwvnu6qdd+d1xhMph0O1Q2o7tKW8KgrUFNGDp0rmV/XXlJWUnHzac7B+aXpq2czuJm4z5Quz6CDzJU2zO3NPqO6ivuVpZW6HAlmTX5aqM7eTpkaoS+FNw6Y7/CMPdDo9ECtRa2Q== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MWHPR1201MB0255.namprd12.prod.outlook.com (2603:10b6:301:4f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Mon, 25 Apr 2022 03:45:36 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:45:36 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 02/11] devlink: introduce line card info get message Date: Mon, 25 Apr 2022 06:44:22 +0300 Message-Id: <20220425034431.3161260-3-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR08CA0253.eurprd08.prod.outlook.com (2603:10a6:803:dc::26) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: ff48d5d1-b10f-4ae6-6b3f-08da266e0eb9 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0255:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: Yjg1mQk55OjlgDz4IFgL5+6mdRLb8dj3gtiHD4alfTEeZlQi4bKWGUfmhidEgrd2O1AtuVhyvIRpPB+CTRfQYq5jIv8n6jYTBZRYGmzdAn2hZMSwNVwCDIyMikTsQad1E7jDVXYYIzTRSWr2nL1tU6Ltl7Hx1zULRO2pW0x4OgLfb/Y48HYbGZIlgBEQLKUGgJqDHeRPn/SVcZLAgN6DpV5TnNp8MlvgCfFlvL6wg6OPxfSLrl53ek0TlGdDtAHaZy7cegV2hZJtTK5sPrH0c8p/Q5scu/i4kwZFXQZU6MGmgU0uuMuTudlyZtV4JWqZKENb77fS+bZ/MAkFnmvOC7+gblX5kSqn57SoaJZ28m1sFOzC40XoT9tOgGjOdeUfnKJRL32R5gzOj2Th+1ByNWcCQ00bsUkTYVp5HlHwb93XN1Xgzojomwh4JAPoKBkjhIFDn796JAYFp5Oldrw4TPId1ZiBu5p/d9dCds6d7YG4Ls9AS9XKozlbDlbUcXBFprzF7GS/KkubM0WMK1mbmkIrxfvTthceCHerbmhM9jsuAZ71m2mBi6CvZ4a2e/YJPAtXxprbo/4wPosqYFLj7ZKTHicXrNAc8W6y6/hIhNuL6bySMjXq0+4ynCvxsgnuA/RFYivodk1YALtH0YvWmg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(316002)(6486002)(508600001)(8676002)(66556008)(66476007)(86362001)(6916009)(38100700002)(66946007)(5660300002)(15650500001)(6666004)(6506007)(2906002)(36756003)(6512007)(83380400001)(26005)(186003)(8936002)(2616005)(1076003)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: iAvC2JYe7j7Qbu4Y6W0RRt4/tcbTDxcsMx3NsX51IwGVQz6wrcSkjFep17XTnIjBk+XnTPmYRvRoeqiULkLwbmxg6k9D67LlMLXAQaffXgp6ozrbDMUI3KXg0hrwP+bL7s0IYx44Irc2TWgngUGdW7oYfroA3hIXsc295bZrkHa72PqRHqPVccUuhYbjgF73BXIechE5Eh09HB6wAiATCgMK4Hnxki0e2a5TbaohcNZyW4LBEOyqoPE9Y2aXrBVolSChPIIi3WV/Ro0MketWdFZkSx7PTj4gGE/Sr89zO/oCv9S9MKxCSYuzclt+cuIWCnYXk0g9ggNtXdFnJ9SGoXDU7zAzUcHI0EPY7VMXx7v7IGzdkXB6RUxAnbcYOuM1iOPcobDRS7AArttzwiMxnGGs7PkbDsjYNu2gS/Idp7h5XTw92HX+PGf/JvHSjX2W9dO5XK8h/LESbxqPuEgdslYvsTi3h32U6/UaZaak/ptyGKTRRcG39RRyUSIwQE3VCpHr5SCS6lWU9/MLo/EM31b5oCSSA4zsORapNHdkaNfqMd4KTZPZOcPx7mXKN3vGgAcc9yNTpt3sa9vItXZ1DZ3Y+cYyDZgWCFh66kDZFaW5eWBipzyYyoHe6IsVb+giTpg+x4nc8fTSuRzUsdHdh9pO7OHVCM4HmNbd/yISB2mlDMPd2ePwv78NtSuYbV8QHO/wB/AYuH3ICbqj/3Zkap068bOxZzwJRKy0VRg5jPs8SRli1Kp4XikYqvsKzJk15zUzeiEAMYj11A97AiUWh6d9tZxV7AzjxLbNTu7lTbwz3NICHB5Dn5JxNZ7G5NjhX6VV9mZgQuIEx1GUcACCuO7K7DtwGxihv7ZvQ5+8648KXU37SpaFuWdAZ7InP6lWYBKWNp3qvoXyY5NMKUhp+e4FSkvF3IGd7fmeet1lsDxfe8Uvh4WOutvgkYmAiksU3oZ0JPaZuAA4M3BVhgENq+hNTZGCIKGj2tLnrzkiaTz029NuIdFgDcEFH8XKOm8SuowdqJYRDuHjXJoIgQIS3S11LHmvlyxeYwm9XFrIAbyiBnzom/5tGTJNfzsN7NqHImLPzqItCg8HeYzNpFMQdQP5NEEV1WNl7OGcjmbfV+t2dnf6JeY3caVLnjBjArSXP+nKGjRNjl9+Zh6BWfBG0L6Pu86O2TIMOcf5uX4Jr2XzxdPJWKJ+lfMI5MZ/Hlw3am0HPeos7Z/XhzeQCNjft84dgm1VqOLa4aVV28hz8YtB0a37VF7aDRkS+7aAx6fneTIcZegOCvjhjd7U6aW2IHagX7ElwaQ4mvBRVQ7V/yPhnzxU4pW8PZdT8v0NwcUuPDBDa27rc4Fs7cZZw9lWmJwl1hGt58gNaFr0KWly52RBmZYiBkW5jZq5dQFbT3zeYJ/Xiazjm5fzi/r7sznyJEd+B5ChkePclo/BdlJdmniYqsVwxwW9l2qNWC2zes9N85wDsf+YcZNgIWjFnsZBkK6VjvtZfsCgqyJMxwnxyiHj7I0PkvA6zwYoGR9yUeXk62VNq1zMzCq41ihOtKHfTpG+4N+mnaiEUUouDRcg9T7GqQnInfdRopaOyhCZoikLa2A+uuqCbxIjs0oIJuUv7VN7m68UfoufH0zZlZ5FlPt2znWNaFf88VlTYfj4X1kJEwYCwF0zqQrni7dxgrwf8+EcWhCk7gduuAQ80kponuHhDcrlUxxoz/+Qj7lAf+ZsbOZkE0u71I/srRtKwp8D6Q== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: ff48d5d1-b10f-4ae6-6b3f-08da266e0eb9 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:45:36.3820 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: FoR5qqm3hj0WLWdmTmrq/l/3D+TRGDOtmBKtVjnWJq4Gb/CSogDmk1nQV37sN4KC3a8jQ+kTFsB0k14z4Ey/8w== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0255 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Allow the driver to provide per line card info get op to fill-up info, similar to the "devlink dev info". Example: $ devlink lc info pci/0000:01:00.0 lc 8 pci/0000:01:00.0: lc 8 versions: fixed: hw.revision 0 running: ini.version 4 Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../networking/devlink/devlink-linecard.rst | 4 + include/net/devlink.h | 7 +- include/uapi/linux/devlink.h | 2 + net/core/devlink.c | 130 +++++++++++++++++- 4 files changed, 138 insertions(+), 5 deletions(-) diff --git a/Documentation/networking/devlink/devlink-linecard.rst b/Documentation/networking/devlink/devlink-linecard.rst index 6c0b8928bc13..5a8d5989702a 100644 --- a/Documentation/networking/devlink/devlink-linecard.rst +++ b/Documentation/networking/devlink/devlink-linecard.rst @@ -14,6 +14,7 @@ system. Following operations are provided: * Get a list of supported line card types. * Provision of a slot with specific line card type. * Get and monitor of line card state and its change. + * Get information about line card versions. Line card according to the type may contain one or more gearboxes to mux the lanes with certain speed to multiple ports with lanes @@ -120,3 +121,6 @@ Example usage # Set slot 8 to be unprovisioned: $ devlink lc set pci/0000:01:00.0 lc 8 notype + + # Set info for slot 8: + $ devlink lc info pci/0000:01:00.0 lc 8 diff --git a/include/net/devlink.h b/include/net/devlink.h index c84b52fb9ff0..f96dcb376630 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -150,6 +150,8 @@ struct devlink_port_new_attrs { sfnum_valid:1; }; +struct devlink_info_req; + /** * struct devlink_linecard_ops - Linecard operations * @provision: callback to provision the linecard slot with certain @@ -168,6 +170,7 @@ struct devlink_port_new_attrs { * provisioned. * @types_count: callback to get number of supported types * @types_get: callback to get next type in list + * @info_get: callback to get linecard info */ struct devlink_linecard_ops { int (*provision)(struct devlink_linecard *linecard, void *priv, @@ -182,6 +185,9 @@ struct devlink_linecard_ops { void (*types_get)(struct devlink_linecard *linecard, void *priv, unsigned int index, const char **type, const void **type_priv); + int (*info_get)(struct devlink_linecard *linecard, void *priv, + struct devlink_info_req *req, + struct netlink_ext_ack *extack); }; struct devlink_sb_pool_info { @@ -628,7 +634,6 @@ struct devlink_flash_update_params { #define DEVLINK_SUPPORT_FLASH_UPDATE_OVERWRITE_MASK BIT(1) struct devlink_region; -struct devlink_info_req; /** * struct devlink_region_ops - Region operations diff --git a/include/uapi/linux/devlink.h b/include/uapi/linux/devlink.h index cd578645f94f..fb8c3864457f 100644 --- a/include/uapi/linux/devlink.h +++ b/include/uapi/linux/devlink.h @@ -136,6 +136,8 @@ enum devlink_command { DEVLINK_CMD_LINECARD_NEW, DEVLINK_CMD_LINECARD_DEL, + DEVLINK_CMD_LINECARD_INFO_GET, /* can dump */ + /* add new commands above here */ __DEVLINK_CMD_MAX, DEVLINK_CMD_MAX = __DEVLINK_CMD_MAX - 1 diff --git a/net/core/devlink.c b/net/core/devlink.c index 41d9631ceada..5facd10de64a 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -2424,6 +2424,125 @@ static int devlink_nl_cmd_linecard_set_doit(struct sk_buff *skb, return 0; } +struct devlink_info_req { + struct sk_buff *msg; +}; + +static int +devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink, + struct devlink_linecard *linecard, + enum devlink_command cmd, u32 portid, + u32 seq, int flags, struct netlink_ext_ack *extack) +{ + struct devlink_info_req req; + void *hdr; + int err; + + hdr = genlmsg_put(msg, portid, seq, &devlink_nl_family, flags, cmd); + if (!hdr) + return -EMSGSIZE; + + err = -EMSGSIZE; + if (devlink_nl_put_handle(msg, devlink)) + goto nla_put_failure; + if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_INDEX, linecard->index)) + goto nla_put_failure; + + req.msg = msg; + err = linecard->ops->info_get(linecard, linecard->priv, &req, extack); + if (err) + goto nla_put_failure; + + genlmsg_end(msg, hdr); + return 0; + +nla_put_failure: + genlmsg_cancel(msg, hdr); + return err; +} + +static int devlink_nl_cmd_linecard_info_get_doit(struct sk_buff *skb, + struct genl_info *info) +{ + struct devlink_linecard *linecard = info->user_ptr[1]; + struct devlink *devlink = linecard->devlink; + struct sk_buff *msg; + int err; + + if (!linecard->ops->info_get) + return -EOPNOTSUPP; + + msg = nlmsg_new(NLMSG_DEFAULT_SIZE, GFP_KERNEL); + if (!msg) + return -ENOMEM; + + mutex_lock(&linecard->state_lock); + err = devlink_nl_linecard_info_fill(msg, devlink, linecard, + DEVLINK_CMD_LINECARD_INFO_GET, + info->snd_portid, info->snd_seq, 0, + info->extack); + mutex_unlock(&linecard->state_lock); + if (err) { + nlmsg_free(msg); + return err; + } + + return genlmsg_reply(msg, info); +} + +static int devlink_nl_cmd_linecard_info_get_dumpit(struct sk_buff *msg, + struct netlink_callback *cb) +{ + struct devlink_linecard *linecard; + struct devlink *devlink; + int start = cb->args[0]; + unsigned long index; + int idx = 0; + int err = 0; + + mutex_lock(&devlink_mutex); + xa_for_each_marked(&devlinks, index, devlink, DEVLINK_REGISTERED) { + if (!devlink_try_get(devlink)) + continue; + + if (!net_eq(devlink_net(devlink), sock_net(msg->sk))) + goto retry; + + mutex_lock(&devlink->linecards_lock); + list_for_each_entry(linecard, &devlink->linecard_list, list) { + if (idx < start || !linecard->ops->info_get) { + idx++; + continue; + } + mutex_lock(&linecard->state_lock); + err = devlink_nl_linecard_info_fill(msg, devlink, linecard, + DEVLINK_CMD_LINECARD_INFO_GET, + NETLINK_CB(cb->skb).portid, + cb->nlh->nlmsg_seq, + NLM_F_MULTI, + cb->extack); + mutex_unlock(&linecard->state_lock); + if (err) { + mutex_unlock(&devlink->linecards_lock); + devlink_put(devlink); + goto out; + } + idx++; + } + mutex_unlock(&devlink->linecards_lock); +retry: + devlink_put(devlink); + } +out: + mutex_unlock(&devlink_mutex); + + if (err != -EMSGSIZE) + return err; + + cb->args[0] = idx; + return msg->len; +} + static int devlink_nl_sb_fill(struct sk_buff *msg, struct devlink *devlink, struct devlink_sb *devlink_sb, enum devlink_command cmd, u32 portid, @@ -6416,10 +6535,6 @@ static int devlink_nl_cmd_region_read_dumpit(struct sk_buff *skb, return err; } -struct devlink_info_req { - struct sk_buff *msg; -}; - int devlink_info_driver_name_put(struct devlink_info_req *req, const char *name) { return nla_put_string(req->msg, DEVLINK_ATTR_INFO_DRIVER_NAME, name); @@ -9139,6 +9254,13 @@ static const struct genl_small_ops devlink_nl_ops[] = { .flags = GENL_ADMIN_PERM, .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD, }, + { + .cmd = DEVLINK_CMD_LINECARD_INFO_GET, + .doit = devlink_nl_cmd_linecard_info_get_doit, + .dumpit = devlink_nl_cmd_linecard_info_get_dumpit, + .internal_flags = DEVLINK_NL_FLAG_NEED_LINECARD, + /* can be retrieved by unprivileged users */ + }, { .cmd = DEVLINK_CMD_SB_GET, .validate = GENL_DONT_VALIDATE_STRICT | GENL_DONT_VALIDATE_DUMP, From patchwork Mon Apr 25 03:44:23 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825240 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 6B8A7C433FE for ; Mon, 25 Apr 2022 03:46:12 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240997AbiDYDtG (ORCPT ); Sun, 24 Apr 2022 23:49:06 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42192 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240977AbiDYDsq (ORCPT ); Sun, 24 Apr 2022 23:48:46 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2050.outbound.protection.outlook.com [40.107.94.50]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id AA596237C9 for ; Sun, 24 Apr 2022 20:45:43 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Ek4Kqv60K4YR4ekJzTIq9CSW83ufkxQjQcAsFH7FdkbefegDTuiolbb6H90nLntJqerdcaXld3oOtGd/lmEFg2h0R7GsDGhniBQR8JKBWhB/JenvZBteAweGVkNo0wnhksyuHafIXp0jVYPfCaOYdhZNTWJ3jm9w2WX0PIfyJZvk99nPTm5zObB9W5SafzuTAEfePQehuN+xvhlg2Gy1sLbpXC2N6hDl9IE3YoYXHKCjeHU59eo5e1fcojf1rMnJsFa4n9PDt+lJJyvC3TpDxGwOMKZBbvelSLjs2fCx4fu3rmwgN9IFruDDcYcZeRbV9hFzyy3fRhhYl8sFFnhn2w== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=O2u3csPx3GGhJt8VcMZX1wcM21evXg03DSNudL6iAa8=; b=aHqGZ2LDpL+/T3vdKMyZrlvYct/3uIq3kBkv0nP08jImA2AeqsEPt3lLCiGU33KyILXBb/6GQqTDTN7lNkZoemSy62VsKIDFlh89sM8Li5YXIv8bQBMz5PoQs4PMkqKl6UbE3LQ8y6boMH5GOiBzb6SQaAxKshy0jFIx2o5PbIrGLEa2pVS1nC4TettN+UkkncuX5i9c9wses62NwEcsm2fXQNr10h9YO5/2PKKDsGgStj3gARpDNHE5JEGO3LGQ5b4AR1WVazUHHmhDydmWSpag0l885LXKEcLW6Za8z4kSPFP3Mq7QodB2rLwztuFvC94SR3HmRv4vOAA/c+UxsQ== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=O2u3csPx3GGhJt8VcMZX1wcM21evXg03DSNudL6iAa8=; b=nN9+2hifzkIWUmo7l31SBbwlE3PXqI6Gukr6sVGOH3z8X9HTb+jecNKNnqcE4v2CX5gQSR0UH/B0zjsTWP+eSWspm1WU5hZ7aORzJtMRs9OO72FrbxojK3ROJLPbr4OZXtWth6lkknehrV//vZFHIzT0TaZZR2m7nScVJRaPVFaJcGQczZFrj1c4biDRPRDRlNSx596STTBPhJfOdKI+m/3A0dX6bUn0oC10oLx5z/kH8OGXsFlniyUdsNw+ghheokOTOfIK1H1LjTpKIzk1A9b4yhn4mT7fu79bd2wguCt+OoK5qRHnHOagtJHBCdRtIXuwzmioO/p6I/KljnzZBg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MWHPR1201MB0255.namprd12.prod.outlook.com (2603:10b6:301:4f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Mon, 25 Apr 2022 03:45:42 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:45:42 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 03/11] devlink: introduce line card device info infrastructure Date: Mon, 25 Apr 2022 06:44:23 +0300 Message-Id: <20220425034431.3161260-4-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR04CA0128.eurprd04.prod.outlook.com (2603:10a6:803:f0::26) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 2794882d-3b39-4a7d-f75a-08da266e1226 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0255:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: xfwkNFlmn7RIDC+PtuDs3u2x7m6GaeB/jdRYCkLXERNwWNKO4qmP00E5xLCSTDbpXob6w1ZY4e3WniTfF+rLPrxwXRmHcLArWuQVg2GXPihcbN85J+2RkI5jDY2Zw1kPQswg89kMJub72mDuAxwUoYA4bNkUxObfH9qm79KLFRqol1cWYie83LhB7ATSfBdkLfz/N/nwqCSuPz2M0hKKj/HhycLBsSzdjK1JeFP67Zc1kHpXayJAvK9q7B4p4x84kldddid0MrlTPB36UHsUcfnuvC8cd7OsEFOAM++L1yVSL6LNLCU6BGZ4EXS/7r5RipkYy8PPn4olecJ+QbIVtjQwFHFbA67BWu+BFj7dLXgL3H9K6m0kxcBgl53Zr+/Ojfpv41KMHwYmcQa5V5loJQX6NcBwzJrHuOS/BZffJMxTZxxUq4qDxafJw8pMHUUxgjBgxF7rSr5U0eEoElms3QgAUekwEloiJy6F9EHmsAWACzC08DTqxQ7+zZ9acnOfSyl8bKoLhuHUHQqHBs1JIDnwLkCebn1XyneNk2qouypPNsx/kbI2s3A7nGe2GQDoA/Ke9/oon9MoWkRvJQC5yhzrxfgcTkHxfuQPtmICKkxXamvwil7SQAOpvZsMG1nQxRFJmK34gpZO3HSLzZmhjQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(316002)(6486002)(508600001)(8676002)(66556008)(66476007)(86362001)(6916009)(38100700002)(66946007)(5660300002)(6666004)(6506007)(2906002)(36756003)(6512007)(83380400001)(26005)(186003)(8936002)(2616005)(1076003)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: ORynhq5H6qPBD0pOw5SNDcWI28Dfhb0GIvhiS+XcFTwmnGgFvTrhsY6qvdAYctqpsGqacmgMLw6/o60W3FigYZA6x2mZbRJJZSmYpg8+VmY2cG2Y81asKpkBuqRCimlbe4fO5BfdJIZPT3otnoTcF9DSE5XhbzzjlhsmgJtXAtb5UGtndYPSRsJAL+Qx0sYMIO9b8r8sQpIvi4u+Csbe88zW3JCz8QasSVzDh2FBlA1vcZQpnkh671FvYBbSXpsgMPp4tyHAADQuyFmTiJkgAqdwnKUtsGnPrHAuthMZUcPoCTE8Xj2Q6vx5ekGOCMvh6GnvqJ3z88m0BaBTyI1g/Y2IoxsskgblbJ38YwToR/YWm9ojfBX2CSRxIInfSQf9GSVIfzT4okuREQB3cg9UNToMpiZ+9sVKuv4lzs9IiB6xsUz1cAhX8WaejEh40ZqUdcbAvCORjSkueSPGDdsntSmSmKAFq0vzxAwQxcl6IS6S9BSnk3x/gYOQd6DpWTsFNvHsSr5sFnW4O+8WzlkABF0OaEKnE3weS3Q0Uqva6DuCsUdlUlWYb0rBJEnWDhg+h39ktO1j5CxRTcS0+yJTQ9SiG1P45YEU/zPOlWngRkAP84Z162A42Zjz6rP3UC666FvNvDo4aOmcfz9iaJXYODzJ8gsarBTyWNPTtBjkoj/6alcTTfj7XycEfpr6+8hHP5TV5qhVoObiIDGKAFuWn8FCYzGku5pirE98FyAreJ3WiIc1Hd02ADUbn5AcqIbuP9uHzlV28VwnXh2RnI4t+RC3v5/kiNo+R5+2ZLikbHz4qqeMIs7UaxaGrW22P21i3//QKINvn40HjOS3KbOu2v6Wy0NdtLeIRWuvyiks8nTGVN6Y4zlXivfv1JDK0tz2CEtQzXlO54jwPS8cdvrhp64mS6vEX7+td8n0uvdiijWaYDDf/l3K8FHOcWWD5uXLbO9lW1KFML4WN+QubfNjssWpz/OViIshKrNsORyB+88djbkKLjLBp+yRzEwS9wcFu44qSwtgKwH0hoZQ+qo7yhsXZtC/CyHbdCu/5s63/71AVI4KzAP2+KXE8g0KautAEwLi6ke5QtKFvorcZYS95wiFvRVh7eIr9YtU+SXI2wFqR4O7Fx083dpLarP85KxbGJ2tM39Wpfw5TDrcB8ETWrgL1YyjYM5gG2VqFt5qF96l5pP3IrmFz38rQrm65LHm8B8J/MvnGjh6f9rrrF0h8kuWF0GFH/Z3yBOMucmj/+qynhAqp4iTzqZuQYlctDH17GGdTACCVN/Ru3+ZD/x5JGQPMhJANMfGCAaec/XQ1iSFlhGgMviGH3LBUifdrIi5p0H68umTQL7MeWrV1WiOG+ezu+ffBXBj+nr6cnV/s1ggzoNpVpeNzKUj60dVeNttUKyrUL9zDtZfp33WHlE5PleaBXJEpG4Xf5P4/O3mq/HwxYkRujPkfx6EV2W3N+2wIE33Mxeo4o4px/kR881uS1ezj0Qfz3AK8G5PltoomWhT3Ep8Tx1u+dl6X6PMxBFxvrICR1aqY4FPVVwhsi0uaUK6ZClA+FckinxIDYqJ9zOgUR8RZ35mYAcumI14JuyeruWNUpqvGUCEivAGtJPCm/JIo9K8HYYDX+tiT2zw15bt44CQj7419TCUet7uhSUDfrdsFm36jDL2ArUxT2hZt6XuE9pYh8Qu3vU2Mu86vZ4AFOmXgB0vQOzmxc7tdbueS7RK5ahINxCtLxkMTV3eQw== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 2794882d-3b39-4a7d-f75a-08da266e1226 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:45:42.0554 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: ebTkyCoIpeSg/J+D2Nys7H3UgsdyHzVfMvbfXkvK2WW+xIdTI419v83zJKNoAs5P+f5zH1mvwrqBc71bL+st2g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0255 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Extend the line card info message with information (e.g., FW version) about devices found on the line card. Example: $ devlink lc info pci/0000:01:00.0 lc 8 pci/0000:01:00.0: lc 8 versions: fixed: hw.revision 0 running: ini.version 4 devices: device 0 versions: running: fw 19.2010.1310 device 1 versions: running: fw 19.2010.1310 device 2 versions: running: fw 19.2010.1310 device 3 versions: running: fw 19.2010.1310 Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../networking/devlink/devlink-linecard.rst | 2 +- include/net/devlink.h | 8 ++- net/core/devlink.c | 71 ++++++++++++++++++- 3 files changed, 77 insertions(+), 4 deletions(-) diff --git a/Documentation/networking/devlink/devlink-linecard.rst b/Documentation/networking/devlink/devlink-linecard.rst index 5a8d5989702a..a98b468ad479 100644 --- a/Documentation/networking/devlink/devlink-linecard.rst +++ b/Documentation/networking/devlink/devlink-linecard.rst @@ -14,7 +14,7 @@ system. Following operations are provided: * Get a list of supported line card types. * Provision of a slot with specific line card type. * Get and monitor of line card state and its change. - * Get information about line card versions. + * Get information about line card versions and devices. Line card according to the type may contain one or more gearboxes to mux the lanes with certain speed to multiple ports with lanes diff --git a/include/net/devlink.h b/include/net/devlink.h index f96dcb376630..062895973656 100644 --- a/include/net/devlink.h +++ b/include/net/devlink.h @@ -151,6 +151,7 @@ struct devlink_port_new_attrs { }; struct devlink_info_req; +struct devlink_linecard_device; /** * struct devlink_linecard_ops - Linecard operations @@ -171,6 +172,7 @@ struct devlink_info_req; * @types_count: callback to get number of supported types * @types_get: callback to get next type in list * @info_get: callback to get linecard info + * @device_info_get: callback to get linecard device info */ struct devlink_linecard_ops { int (*provision)(struct devlink_linecard *linecard, void *priv, @@ -188,6 +190,9 @@ struct devlink_linecard_ops { int (*info_get)(struct devlink_linecard *linecard, void *priv, struct devlink_info_req *req, struct netlink_ext_ack *extack); + int (*device_info_get)(struct devlink_linecard_device *device, + void *priv, struct devlink_info_req *req, + struct netlink_ext_ack *extack); }; struct devlink_sb_pool_info { @@ -1583,10 +1588,9 @@ struct devlink_linecard * devlink_linecard_create(struct devlink *devlink, unsigned int linecard_index, const struct devlink_linecard_ops *ops, void *priv); void devlink_linecard_destroy(struct devlink_linecard *linecard); -struct devlink_linecard_device; struct devlink_linecard_device * devlink_linecard_device_create(struct devlink_linecard *linecard, - unsigned int device_index); + unsigned int device_index, void *priv); void devlink_linecard_device_destroy(struct devlink_linecard *linecard, struct devlink_linecard_device *linecard_device); diff --git a/net/core/devlink.c b/net/core/devlink.c index 5facd10de64a..5f441a0e34f4 100644 --- a/net/core/devlink.c +++ b/net/core/devlink.c @@ -2062,6 +2062,7 @@ struct devlink_linecard_type { struct devlink_linecard_device { struct list_head list; unsigned int index; + void *priv; }; static int @@ -2428,6 +2429,68 @@ struct devlink_info_req { struct sk_buff *msg; }; +static int +devlink_nl_linecard_device_info_fill(struct sk_buff *msg, + struct devlink_linecard *linecard, + struct devlink_linecard_device *linecard_device, + struct netlink_ext_ack *extack) +{ + struct nlattr *attr; + + attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE); + if (!attr) + return -EMSGSIZE; + if (nla_put_u32(msg, DEVLINK_ATTR_LINECARD_DEVICE_INDEX, + linecard_device->index)) { + nla_nest_cancel(msg, attr); + return -EMSGSIZE; + } + if (linecard->ops->device_info_get) { + struct devlink_info_req req; + int err; + + req.msg = msg; + err = linecard->ops->device_info_get(linecard_device, + linecard_device->priv, + &req, extack); + if (err) { + nla_nest_cancel(msg, attr); + return err; + } + } + nla_nest_end(msg, attr); + + return 0; +} + +static int devlink_nl_linecard_devices_info_fill(struct sk_buff *msg, + struct devlink_linecard *linecard, + struct netlink_ext_ack *extack) +{ + struct devlink_linecard_device *linecard_device; + struct nlattr *attr; + int err; + + if (list_empty(&linecard->device_list)) + return 0; + + attr = nla_nest_start(msg, DEVLINK_ATTR_LINECARD_DEVICE_LIST); + if (!attr) + return -EMSGSIZE; + list_for_each_entry(linecard_device, &linecard->device_list, list) { + err = devlink_nl_linecard_device_info_fill(msg, linecard, + linecard_device, + extack); + if (err) { + nla_nest_cancel(msg, attr); + return err; + } + } + nla_nest_end(msg, attr); + + return 0; +} + static int devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink, struct devlink_linecard *linecard, @@ -2453,6 +2516,10 @@ devlink_nl_linecard_info_fill(struct sk_buff *msg, struct devlink *devlink, if (err) goto nla_put_failure; + err = devlink_nl_linecard_devices_info_fill(msg, linecard, extack); + if (err) + goto nla_put_failure; + genlmsg_end(msg, hdr); return 0; @@ -10483,12 +10550,13 @@ EXPORT_SYMBOL_GPL(devlink_linecard_destroy); * * @linecard: devlink linecard * @device_index: index of the linecard device + * @priv: user priv pointer * * Return: Line card device structure or an ERR_PTR() encoded error code. */ struct devlink_linecard_device * devlink_linecard_device_create(struct devlink_linecard *linecard, - unsigned int device_index) + unsigned int device_index, void *priv) { struct devlink_linecard_device *linecard_device; @@ -10496,6 +10564,7 @@ devlink_linecard_device_create(struct devlink_linecard *linecard, if (!linecard_device) return ERR_PTR(-ENOMEM); linecard_device->index = device_index; + linecard_device->priv = priv; mutex_lock(&linecard->state_lock); list_add_tail(&linecard_device->list, &linecard->device_list); devlink_linecard_notify(linecard, DEVLINK_CMD_LINECARD_NEW); From patchwork Mon Apr 25 03:44:24 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825241 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id A05C8C4332F for ; Mon, 25 Apr 2022 03:46:16 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S241010AbiDYDtN (ORCPT ); Sun, 24 Apr 2022 23:49:13 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42466 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240984AbiDYDsw (ORCPT ); Sun, 24 Apr 2022 23:48:52 -0400 Received: from NAM12-DM6-obe.outbound.protection.outlook.com (mail-dm6nam12on2051.outbound.protection.outlook.com [40.107.243.51]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id C11FA19024 for ; Sun, 24 Apr 2022 20:45:49 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Q/NVcFTKUgJowGfTFDHKwaEyU1grNqxJk9mheowePwGVEN06H4EDy+ikah6UxIFNXSaki904aTmNUWXEinPLZzKB4gLODGVMA0dJrNtmx9SvFGnKqRTcQdRG/9Dzd4QAOcasyv4ReJFQR2FyKDjM3V33F0WdK9iIhT7upeoM00u0MO7mkbu+DeuyHHqoFW24ddAlCJnadVWJfPP0uZIZlp7n7KNblxPJfMiCRy/Emp9AmsQaOR8hu99o0+cIDHNT5FmUuhyN6dhaS6eCQi4STVwAXMVu05zgZHlUIQ5rmOT15iW57hqt5tOsfxuG53eV5Zv7WK3868fLxCK391XL5Q== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=iPZK+r4l1krYXRnt4SBgIhRUTlfLb/IHVCbc3m/CHsU=; b=AkCzCb1unJh54FQWH36JNCZTaJlDUXlJMPHe3Zq3q4l96PN9ZrY6RqNzeunL5BI1xsuOcpeL4C/O1hS86i19MQN36yg1RZmuQN5GtrDVYOv/A2kzX9j0qFuNSE3KpnSiD3EmZQ4CgF36WnepKFQo67wgR0M4/DRxSzWBzhN/3hNNuEa4aHVT73Rya4ezwJK7Dl8rsJwgqaC9Ezp/DWyZUG4Xqo3M7izLtl0mFrWoxXGf+6ABgLwBpIMV4pVGE9GaWhIWJrURXBFr/G5LQzCUEC4u4HOC4Hy1sVYVta5zJAuxtg3BJ364DLL056IjnufggmmbBWpMp1vV/+yyCiXZ7A== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=iPZK+r4l1krYXRnt4SBgIhRUTlfLb/IHVCbc3m/CHsU=; b=sxN3IMhDvD+x4YHLVV/Xs3Lm5g1aE1jvSqSIgS270J5ZK9nkSXGuJQy4jFtAP5ZrbZzvGG57IF/4cQ5lXU1iVxwTdwG5SCXmbkAonUmom1835u/oHPofK/NgQrnvkf6saT4t/a+Hr2tgWv2qKvnTsMLjUC+xAVGbX+Iqq/AntTSUGRDK4zQ5HvF7teNPmG8z6+oypD+stmwLl1c+rAJRFMgeiumQs9Cj4bzdvkTUkYdoF3z7Jg9BZRd0k3n4xLsVTTa+z72sdjxnYiOtJayuukQct6/Yt5KynZ/mnj11eJPaheJEfrP9SZCiVy0wVZt3MN7dni1tuFbQqPCygUOH9w== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MWHPR1201MB0255.namprd12.prod.outlook.com (2603:10b6:301:4f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Mon, 25 Apr 2022 03:45:48 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:45:48 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 04/11] mlxsw: reg: Extend MDDQ by device_info Date: Mon, 25 Apr 2022 06:44:24 +0300 Message-Id: <20220425034431.3161260-5-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR07CA0248.eurprd07.prod.outlook.com (2603:10a6:803:b4::15) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 3f053c2d-4098-411d-f275-08da266e15c1 X-MS-TrafficTypeDiagnostic: MWHPR1201MB0255:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: qUBQVP74MYPT2VOHQ/kkBEETFR7V5Do+Vo9HPtef94+QuXY4OVqPrFpQwtpKuAsGKnyZqHLjBvcSOXn6i4NMYWamKpzBzyVgbPW+kxuMPjHDomqEAM6+i/iy1EnCZRs4IMELs9NHNbRCE3RncQx0bCIXHt/eLj9gNLvYQe6p/QSlaw40V3aNBEtMobSkitXpy2H0hH1O/BBHHr3d0qw30F6FlvXeAf06niGL9S70Ck6LLSnGgTewkLCO6PCEBQwwpwugxl5bGoeHq6P958ZdeKgNpKTUSUlGc/dnTCIQLg5z1+5T+KfxP9HtBqL3pPlT1UgfqecDksHHcaqZFdjJbdXTGlYHhuJa3hUXCx5hSI9BinK52+eSyMrv0/QpU11/+g9d1cMW+edEP40jXya/FDBedRy+HRUVzZVopo8bXkDMGCgZYj1RtNm3+4BxW9OOtUINMbwqzu9fa6V5KBdoOgnW8Ka8jkfuyG2NVTCs2aJ/vmOsYzIi/WP7Ckp3NEbMk+nvrhg/zq72imfrc3AEplBlq2BrG+bRJiA15gWCBR7Gky72xTkC6E3rolRh9OdW6urbIqubUFkS5UKnRj6hnjCHIwuKOGWR0jjTW5adaZXgCk0/gzM/5/ShGfOKIgkxBwJtnJImtZxCY+8K8FktaQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(316002)(6486002)(508600001)(8676002)(66556008)(66476007)(86362001)(6916009)(38100700002)(66946007)(5660300002)(6666004)(6506007)(2906002)(36756003)(6512007)(83380400001)(26005)(186003)(8936002)(2616005)(1076003)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: yn/klp+0Rp68UhuP24C9p5lqEgYbtK+nBmzupie00jAU5XE9FN8Nk947UjOTeohZpcMVIVSG/V8vHCRv4KsER+3y9llUyKme5jJulWv0WKrAXdMJfLmc3wNGqHNAOG4ohev24m8U21wm0GAwIbou/LLaSQH0l9xwLN9sCWVpLuyafMe54z83AT7ixWIazQ/5o7fRSOR3SEII6l7DCd/PlKFCrEbQwRETyVx3+OHRTIk5GZmiR1ua8uoOt75pv6mCQueURuUVY9APVqUWzxz9tJunhCrKQi16C/lu6g2qL1mhpWQPiFZqndnVxT6SprxFNPJ+67hiO/vRYFE0eC6JM5DSWwcih329Y6fn8bQqQS16eCCJvUEcQr8xxvVhmY9fYn3+43BqxC4UWPzYp87/dETTItXmRpx28MYBASuNGY5K7zLfQ0tjM36ijUw7aRm0Wc470ocGZXfebH9fDoFQe7c+vwHNJpSR+5FnAOmhS3OQLz92EENUnsHpscmHHiAzN0MOK/IrDLMk5YvQxR+/zJ3yAk+utSFa4vor+ysPc7pGPTWn9HDsQYfI0jD/BdYmy6g0Sf9HiFzA0vFr0zEdwSYryPCdyTns7SdsVC56P0hlCRkChMUfh6p2oWLPqhooWsxJaa11xNzqMy+io9mYim9DQU9vy3J4cCT/4K7TbfdPxbfT9VDh2nutkxNk63Pt0SrAHh5zCnQhixxeSopVYB9EhoJpNjqSucCITIuAVfmjVyjrgRCoDovY/ewga/a1tZbH1faTTB1wiaaIQ63NLSlZtajrmv8aDSA3NbLIJSyef3yeaZ+NtWuJ36PJpg7P7dMjV68cs3iBmGfSdlzv+Yr1GTzo8Qa2VOCduiSXwzgXq+mNvUAH9UsliEYLl1q/04xxxKq6KZBqj0eGMjodlev6srzjsKswJAQxFmNk2widWIL57vJVnxnKF6qqT1EEoldahky9am5s6nnVr596vEr4okre5y0oFhvRY6lR8oGRFWCIe3BGUvQW8RDXD/b5uJy+18r53nX53P6CVpq5Bq7/E3PIzJFS9i0Y5skLbfVxB95i8p1/oPuflsrfSAKJTweqcjOWVmcr4rgVt+EdhPnUI1zSDwvJtm+FuidIogyDZ+8UE+Ah7NfhughUSKbTUqCNnGnZOc5YHW4LJpFowyUVCYAWdc9/hAuXQkKuQoYbKbmQAh+ym38Blk/0Fm/+ZB12/82fX8x+Df25oJp84KCByrSz/m3V4yYrRRl9z6UqZrU0B2T9TsudEXYF6BhT0Ell510nfGGoKDlOdq+nxQbmZy+hQOrq9atpIzSzAxv98LYXeHIqTYl426eGyqsJxidguhitxnVvAh1bYABUvC2eLxkIjcQ0t0nN5LYl4bXdJUpU2RPmdIfqyxXXJXrsvi32mZp5w9hArS3TyUX/1qTE8v/8lWRErsUMiQBxOX6N+ZBPhPGh7L/ZV1jFZR6MK/nbbHnE91+n+MAOeEKzcPJZ+UFFNTvr1dKyAMyqKsudhtEx75YfBhu7apr82AcF2uZMN1bpQBnORM0sNzd9i4hL+mXWMHu4wNpkTFTR0qZhMHwaHOReg8bYqCXijfCwXraRt95Md5JZkigXqPYf+Higd0CLfq/pMfuIpXQ+WtbeOWfpmcqmcaiZCxRVZscEDfDZvnc3VhyuQawCIjDrFM2Ec8uows1rx2pztYs8IlxuzfjD08M4qqRyuHr83z/1Tpf65fMTe8gVD53StcnGdA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 3f053c2d-4098-411d-f275-08da266e15c1 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:45:48.0730 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: GWjDEAs61Kcn2XB0dozGH4eMDKmMRp9IWgC1cqaRHTStlBm6oz1hxsQ8Pk+e9MpCzT+qSLdMsmzxZchS1HIy3g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0255 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Extend existing MDDQ register by possibility to query information about devices residing on a line card. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/reg.h | 62 ++++++++++++++++++++++- 1 file changed, 61 insertions(+), 1 deletion(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 23589d3b160a..521c1b195a3e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -11643,7 +11643,11 @@ MLXSW_ITEM32(reg, mddq, sie, 0x00, 31, 1); enum mlxsw_reg_mddq_query_type { MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_INFO = 1, - MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME = 3, + MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO, /* If there are no devices + * on the slot, data_valid + * will be '0'. + */ + MLXSW_REG_MDDQ_QUERY_TYPE_SLOT_NAME, }; /* reg_mddq_query_type @@ -11657,6 +11661,28 @@ MLXSW_ITEM32(reg, mddq, query_type, 0x00, 16, 8); */ MLXSW_ITEM32(reg, mddq, slot_index, 0x00, 0, 4); +/* reg_mddq_response_msg_seq + * Response message sequential number. For a specific request, the response + * message sequential number is the following one. In addition, the last + * message should be 0. + * Access: RO + */ +MLXSW_ITEM32(reg, mddq, response_msg_seq, 0x04, 16, 8); + +/* reg_mddq_request_msg_seq + * Request message sequential number. + * The first message number should be 0. + * Access: Index + */ +MLXSW_ITEM32(reg, mddq, request_msg_seq, 0x04, 0, 8); + +/* reg_mddq_data_valid + * If set, the data in the data field is valid and contain the information + * for the queried index. + * Access: RO + */ +MLXSW_ITEM32(reg, mddq, data_valid, 0x08, 31, 1); + /* reg_mddq_slot_info_provisioned * If set, the INI file is applied and the card is provisioned. * Access: RO @@ -11743,6 +11769,40 @@ mlxsw_reg_mddq_slot_info_unpack(const char *payload, u8 *p_slot_index, *p_card_type = mlxsw_reg_mddq_slot_info_card_type_get(payload); } +/* reg_mddq_device_info_flash_owner + * If set, the device is the flash owner. Otherwise, a shared flash + * is used by this device (another device is the flash owner). + * Access: RO + */ +MLXSW_ITEM32(reg, mddq, device_info_flash_owner, 0x10, 30, 1); + +/* reg_mddq_device_info_device_index + * Device index. The first device should number 0. + * Access: RO + */ +MLXSW_ITEM32(reg, mddq, device_info_device_index, 0x10, 0, 8); + +static inline void +mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index, + u8 request_msg_seq) +{ + __mlxsw_reg_mddq_pack(payload, slot_index, + MLXSW_REG_MDDQ_QUERY_TYPE_DEVICE_INFO); + mlxsw_reg_mddq_request_msg_seq_set(payload, request_msg_seq); +} + +static inline void +mlxsw_reg_mddq_device_info_unpack(const char *payload, u8 *p_response_msg_seq, + bool *p_data_valid, bool *p_flash_owner, + u8 *p_device_index) +{ + *p_response_msg_seq = mlxsw_reg_mddq_response_msg_seq_get(payload); + *p_data_valid = mlxsw_reg_mddq_data_valid_get(payload); + if (p_flash_owner) + *p_flash_owner = mlxsw_reg_mddq_device_info_flash_owner_get(payload); + *p_device_index = mlxsw_reg_mddq_device_info_device_index_get(payload); +} + #define MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN 20 /* reg_mddq_slot_ascii_name From patchwork Mon Apr 25 03:44:25 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825242 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 91A8CC433F5 for ; Mon, 25 Apr 2022 03:46:19 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240960AbiDYDtS (ORCPT ); Sun, 24 Apr 2022 23:49:18 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42810 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240992AbiDYDtE (ORCPT ); Sun, 24 Apr 2022 23:49:04 -0400 Received: from NAM10-MW2-obe.outbound.protection.outlook.com (mail-mw2nam10on2063.outbound.protection.outlook.com [40.107.94.63]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 989DF186C5 for ; Sun, 24 Apr 2022 20:45:55 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=iexywxTSjKpGFeVq4+1oHdppZJK7jPqkBP2+rbxqdL0zbh2l9TPI+Hc9KRA6Dv6hzl5LIsrfYrJPBMvN/aVAtWTMo67bt59AJYE/OYzAoYG8t4ORkWnxDkt5XXg1unf01xdy/tto/989P/Ayjhx+1aFkUPcOc3mrQw8ZwNLjqAtFJT5D/2DR77myebz4Km224ob1U0mQeFAHwykZ0smQP23AyS7zJYQJqQDlvCg6TDrRivKFATBRGstRdW6HANSDgNCRDqePROeDvzmRgwxSvSZT0W/4k2h/h0ovwWe0L76Z4avZdtt2aLzxT5RPB8tmuGIkvWigiqq/NliVZl1b4A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=2G97eygCVXG8WLb2AF30bA1N4vugeGp653p6gIpRfL0=; b=cneS4PGD73keIgrpGoJCPYOTDxGoeAmpeHBrgUsb/ylGZnKzvZJ0jFI8cDPq/U4PaLCZ7tjbJLYd8VTbSxLQLEDTiAepAiNZu4RBXXWCiCTaXs8WgrdftDR1Np3W5GTqpBeBjqA1gwdU/bsaVz4SitwJfJtBp7vlU3onuixQWWH/+oSA6SySk4254LydnCh8xjVIG4H9lCgzH7K7R/Vw/4EpNbnX26gquVKWlPxunP2l/neYv2zFEDv6pQ4oyIcZ/lstSwp3nhcI/jCK7/0HSSJ+N0torYL8pxSqE5JoFbN91oYxUbqNmEKZpNsIelXEVet8sds7g5HF7utoANQ8Kw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=2G97eygCVXG8WLb2AF30bA1N4vugeGp653p6gIpRfL0=; b=ZXkJDkX34Z1ZNn7FKxBIKU+Y085hsvM9HSS4DtbcyqOGEMSx9egzdHOtNwuy6FQh6a8uoK3aGxiG6DAeK6W38PaVYjPQf1i31fFC3LZkFhdzZyDk1IHrgkn6O6a0Lyth/A4Qd/aD+YLER2UgzINVILCc36JNIxu5jLgiBqn9mwHg2F9Td96zp3Vztv1Z4BDyIUirA9wWDKOL2Si/AXeRDFcZofT4dtjMgA75xsNsgJ0UZubocEh1AucgZ2FFzTiCf4mGi52zFQar/zf5EHupuIvqRmaSOLRUeLP67trrFciliDO0VqFV9eoRqLp3cLHlF3+ZDH1oYByLJibjhVbfLw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MWHPR1201MB0255.namprd12.prod.outlook.com (2603:10b6:301:4f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Mon, 25 Apr 2022 03:45:54 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:45:54 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 05/11] mlxsw: core_linecards: Probe provisioned line cards for devices and attach them Date: Mon, 25 Apr 2022 06:44:25 +0300 Message-Id: <20220425034431.3161260-6-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR07CA0253.eurprd07.prod.outlook.com (2603:10a6:803:b4::20) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 5064053c-9afa-4bbe-1db9-08da266e193b X-MS-TrafficTypeDiagnostic: MWHPR1201MB0255:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: EiMmPxf/AXPlxfkdmtZSJhQwwjYO21h6njty9gTdEta7fv4Ac/hMhjldZKQAaxFQ70Ro88BVZ5hQ1fZwFEYNR6EWQ3USlytUJOMHacP2d8re/SD4YtLu9mBJEve49squqzfk7HmlnfWiXs++wRzoXn/8Dd/E3MTWYnYjr9LlPlRA4q/qactfnNyty83NQ0balQzH5s2GbQgO7xCWCQU81Viftc6RDnDabg8MNsIqirTWxOGw/NlJLFMIN5IdClNb3nxKQYWc2Gmg+3zq62MmQanS4KkN8iAQ0N8tm9ihWt3rn5xp6EjZQut3XnTLH2or9dsEWxysjxOIrHwNYRg4s/ucsrZODjjy7c0cCFZT+MOxvTN7O4PskOGrR4kmJNroQQHSVaJzDv/RO6AyRb6L3HKpR5krxhtV0OraGlGm452ovB0Xfitk4lSQB7IkFQP5frhEYxhs9seiL7EAs3ICw2qpaPHC4OcJ+ceoFbdZUCOgz3SrRXCFG8+dBJm+eUqiruTBhABCJAZosbXINdn+joxn1LWLoKzLyvXhyxll+hk7zCA3EYOCdPAU5cJaE2r5JHh2o61BoYbWD5aKww0NaWHC65LF23uS6RIczepsHXIYnLItX8IlkIhwU0PwTTieNas0UU3Dqgc8CRP3lzrSTQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(316002)(6486002)(508600001)(8676002)(66556008)(66476007)(86362001)(6916009)(38100700002)(66946007)(5660300002)(6666004)(6506007)(2906002)(36756003)(6512007)(83380400001)(26005)(186003)(8936002)(2616005)(1076003)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: z5gyGXf5PQmBAalMMEifam+F8EXW1xbxrjFnksJ5TduKN5VgmqrAZF5fivh2O2zKzZskRyCDdByxWKgy+RdLKcDnBfSAbAX5Uuws1a8FFsE7hnPoknfTqHWTLbNIbkKrSyXMgfzzuayXq3S1HMS6MXFT00beeaudx1sL9Dy6FLhVijCS4WgtxGqSr92EcqFPNMbUJPvD1+KPGsAkNjLRGs8v1bgfH1DLjDAOCS3+wVmDJSb5SFgRxR0+bXhmG/tZDYVuJHh3gZUt6f5Xcus+cywP7ygz2eAJ54d4Y2dOqE6BJ6yRyMSF1GKVgZot2zeFbi/M40wVIqLTkWbh7l5cKebxQUEqAnbgYEvCmu4v2dd7n56AWCY69Z+pXVI3w3jYdq/glpmOjVOvG1XqJPTkRh2c06O/BNV5eBPdwWas64PNaZe5k1vXh75n1L9OX3jerhtRkmEVfjWrHDPk/javxit2dpmEasUJhkjyYBfwLoISlmuxmrathktSwJp+AJAIx1FkoBwCOUTL3LeSN7Rn+lPKHUGl1jFiX0NhknXQO6UoDzcawy6xeu3Y86EAq0y5wvkJTpOUfUZJi34gZlE6VE6BEYLrwEqoEMEN1N/b/d8kuHdbmczn9Ih3ZczMmTNtarDxkQkG0VoEHMSpU7prgh4Qtd9XI0osxVGurEYvVGBQPwhFafxJf9g+Q7srKYueGqJX7EhEFc4ELRNJdbOoLtmlfRccYHyM9f8hRmYEXEg4jpYLTZPt2/M66jLIKm8sRm8N5VUeeKGI7DvDcaMT1EBg7xnt5iklwCxzpbYcS93ubBPYw6r2eIMRHgEo8T+iTa9kTnQl0ArOf29fbh5yE+FeOL6m6hC27pfPqVkeE9jnSmwYXIDjcQspbjqFyR0/YQNzFE3ERdsKrKLayWLajx2AODcRTwtCWDtWDlio7uVEzxFVWfHbG5UOTz5fNtGZDeJI24B/OR/2q/qHDBVRvaFAL7I0hho4X/tBFZVc3J+YtcDpfcNSYjivh9HqImgiIA262eKAQIlh3RNk/djM791rnX450yb1O3/6nP6bdrC4xLA2JVHut2/r9w0AKUIKgZ9XCNcA5xdigsEyBPsIjaT1wLXVgn+DU2Ua52fmFK+T8DYHJNZyn+XpJrYccGt5dnSDNHoVErsLcj6iP4e4/dGgVVKUU6xaBPLwL/1jH1/evwPXZhVykHoYL7WpTWNAUBR+J+CZFuRGFog1Le7EDO59hi0cTHwihAauXeDzw1YXSAiKb1zAMCULVgC/XN5vrXElpl66sltFCZeMYeKqObrRYO63X67cBNc3FRwPqWqEOCBnXnRtUTYat7t3yik1/Ln03lo2muwrdtFweGiLz87WyJp9x3lq39ApxpGN1a/Qox9LHhNqa3RUWQbY/c8tnbilBmon4TMwh6TLhDVVET9zMq83XsUHehWPqY7WkD0hVXWlZbjKWtPIzwp4oxMYsblvGLKFfNpwnQQM793vsHnpkEn7mvFNhSZTghJjIOr4wk1cDdR423rfO/BBzQumkbet2oBqznUOSfzSQGxhzbESW8+JZl6v+rgQkofYNfCKZsbkzNmsakWNSwWbV3giHnQi3YyEOaMTxnqK/fQez8B+lZOwGMvYlfnYgWAT7tL6RJt5P+xkND8S+85/Yd+uSz/1yzj2SQ6P11TJSTX1Jnqaxg2MdeoQzYwxMXDCfuHRga1x+HXCcYK55CfzOgqoe9ceW7U0uAUpIFyCa6/L6A== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 5064053c-9afa-4bbe-1db9-08da266e193b X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:45:53.9783 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 1cLrs7Sh/Knrce/oipjOy8vwcf3AlTgBCF5rN6S17E0yV/I+s94YlFgjC6l5J86Tf0vw4PiZ9y4cJHYp78XKHg== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0255 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko In case the line card is provisioned, go over all possible existing devices (gearboxes) on it and attach them, so devlink core is aware of them. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- drivers/net/ethernet/mellanox/mlxsw/core.h | 1 + .../ethernet/mellanox/mlxsw/core_linecards.c | 99 +++++++++++++++++++ 2 files changed, 100 insertions(+) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core.h b/drivers/net/ethernet/mellanox/mlxsw/core.h index c2a891287047..d008282d7f2e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core.h +++ b/drivers/net/ethernet/mellanox/mlxsw/core.h @@ -581,6 +581,7 @@ struct mlxsw_linecard { active:1; u16 hw_revision; u16 ini_version; + struct list_head device_list; }; struct mlxsw_linecard_types_info; diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c index 5c9869dcf674..9dd8a56add4a 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c @@ -87,11 +87,101 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard) return linecard->name; } +struct mlxsw_linecard_device { + struct list_head list; + u8 index; + struct mlxsw_linecard *linecard; + struct devlink_linecard_device *devlink_device; +}; + +static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecard *linecard, + u8 device_index, bool flash_owner) +{ + struct mlxsw_linecard_device *device; + int err; + + device = kzalloc(sizeof(*device), GFP_KERNEL); + if (!device) + return -ENOMEM; + device->index = device_index; + device->linecard = linecard; + + device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard, + device_index, NULL); + if (IS_ERR(device->devlink_device)) { + err = PTR_ERR(device->devlink_device); + goto err_devlink_linecard_device_attach; + } + + list_add_tail(&device->list, &linecard->device_list); + return 0; + +err_devlink_linecard_device_attach: + kfree(device); + return err; +} + +static void mlxsw_linecard_device_detach(struct mlxsw_core *mlxsw_core, + struct mlxsw_linecard *linecard, + struct mlxsw_linecard_device *device) +{ + list_del(&device->list); + devlink_linecard_device_destroy(linecard->devlink_linecard, + device->devlink_device); + kfree(device); +} + +static void mlxsw_linecard_devices_detach(struct mlxsw_linecard *linecard) +{ + struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core; + struct mlxsw_linecard_device *device, *tmp; + + list_for_each_entry_safe(device, tmp, &linecard->device_list, list) + mlxsw_linecard_device_detach(mlxsw_core, linecard, device); +} + +static int mlxsw_linecard_devices_attach(struct mlxsw_linecard *linecard) +{ + struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core; + u8 msg_seq = 0; + int err; + + do { + char mddq_pl[MLXSW_REG_MDDQ_LEN]; + bool flash_owner; + bool data_valid; + u8 device_index; + + mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index, + msg_seq); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl); + if (err) + return err; + mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq, + &data_valid, &flash_owner, + &device_index); + if (!data_valid) + break; + err = mlxsw_linecard_device_attach(mlxsw_core, linecard, + device_index, flash_owner); + if (err) + goto rollback; + } while (msg_seq); + + return 0; + +rollback: + mlxsw_linecard_devices_detach(linecard); + return err; +} + static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard) { linecard->provisioned = false; linecard->ready = false; linecard->active = false; + mlxsw_linecard_devices_detach(linecard); devlink_linecard_provision_fail(linecard->devlink_linecard); } @@ -232,6 +322,7 @@ mlxsw_linecard_provision_set(struct mlxsw_linecard *linecard, u8 card_type, { struct mlxsw_linecards *linecards = linecard->linecards; const char *type; + int err; type = mlxsw_linecard_types_lookup(linecards, card_type); mlxsw_linecard_status_event_done(linecard, @@ -249,6 +340,11 @@ mlxsw_linecard_provision_set(struct mlxsw_linecard *linecard, u8 card_type, return PTR_ERR(type); } } + err = mlxsw_linecard_devices_attach(linecard); + if (err) { + mlxsw_linecard_provision_fail(linecard); + return err; + } linecard->provisioned = true; linecard->hw_revision = hw_revision; linecard->ini_version = ini_version; @@ -261,6 +357,7 @@ static void mlxsw_linecard_provision_clear(struct mlxsw_linecard *linecard) mlxsw_linecard_status_event_done(linecard, MLXSW_LINECARD_STATUS_EVENT_TYPE_UNPROVISION); linecard->provisioned = false; + mlxsw_linecard_devices_detach(linecard); devlink_linecard_provision_clear(linecard->devlink_linecard); } @@ -840,6 +937,7 @@ static int mlxsw_linecard_init(struct mlxsw_core *mlxsw_core, linecard->slot_index = slot_index; linecard->linecards = linecards; mutex_init(&linecard->lock); + INIT_LIST_HEAD(&linecard->device_list); devlink_linecard = devlink_linecard_create(priv_to_devlink(mlxsw_core), slot_index, &mlxsw_linecard_ops, @@ -885,6 +983,7 @@ static void mlxsw_linecard_fini(struct mlxsw_core *mlxsw_core, mlxsw_core_flush_owq(); if (linecard->active) mlxsw_linecard_active_clear(linecard); + mlxsw_linecard_devices_detach(linecard); devlink_linecard_destroy(linecard->devlink_linecard); mutex_destroy(&linecard->lock); } From patchwork Mon Apr 25 03:44:26 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825243 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 88520C433F5 for ; Mon, 25 Apr 2022 03:47:02 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S238413AbiDYDt7 (ORCPT ); Sun, 24 Apr 2022 23:49:59 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42876 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240998AbiDYDtH (ORCPT ); Sun, 24 Apr 2022 23:49:07 -0400 Received: from NAM10-BN7-obe.outbound.protection.outlook.com (mail-bn7nam10on2066.outbound.protection.outlook.com [40.107.92.66]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id BEDC11A387 for ; Sun, 24 Apr 2022 20:46:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=hx2zunY8kArq8/QhV7otKk6TrVs7wdlLQzi0hs+mge//8n0jps2NYi47qq/jdJfNtVqeurnPuuYM2CWK0OCzcEYgw6JGxduSXFlZEMW3vhHkHgfpJVjI23xeroP/xyltdYbGwgAnL3d2V8zxZAvsoIyZYvw0P6Uu8nBb0zjG5SurycFqoqTyupWQWAB/ah8BhEeAALopxKTljk8KI2X5JZHkhS3/8FSMgY/OU7Lpg96CW4FOiROrorEIumE2YmXkk7j9wvFNJoDF07S/JK2IhXOtvxuQjAVRIvCVlsQoPIorhocW5RYVjoMD3AxCNiaqKhoOgnClTeK8O2Ba6iM7Nw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=kZLbBvgssw+0Pzp879tujWpRYzoxdtGye4PrKaAGPgA=; b=M7nualsm+JISJLlybeSI0M2iYTteABL+EhGe4n01gxIcwCLdpaw+USsGzQnv87JWRoZugwMoipdtGgXYutWVSedMBFZdlCAddGg7DUR7SAiMz/mf201kDvu2/THNLSzXS65xKzCnWCd4+9C7l4iVHcUC/VfP4PgJwyNZJAElVDBYlfBr16uC2J68DlAF9I9BINxz0muZBW5JPAr6GxdNm7kPL/b65UMSwPRSez+I0etrzkH9t9wyONZY+TKc/RYSSNtMxLcG1o8Oyy+dHy/8PKmw5AbBUhUGMbg59RoX5vjcSqyfjqnvWQf0PFnQXwpY+lkq+QjCT8D3+E4iKGe6hw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=kZLbBvgssw+0Pzp879tujWpRYzoxdtGye4PrKaAGPgA=; b=VSWtL+0v1v9/+n0Ywvdp/VacKd+0CuViCbT7rmKqkhBehdte0nmD1m2QKDLG+AtuApwSZN1dLhEqZFOqbaVoc2f57nuBWJ9KUI03kHwxg+qm5lw5M6LbBHZP3a2rxEYg4RZjotbWP9tVylX60/bWEf76zaxn7s9FCJbKUlw0WveIfn4JZK4ZEkEs4MmWrGdBw71oW01ZysWqpCtCpGwgAHSVCcqERwVKFmtovOz8CvrmORHLQK36anqHrVotk0NCtJkvqQ9G8fwg6JP6i3nEzlVju/GAg2HNZekI/N9yZbOy3EpczSE42wU0+S9V+2r+HXny2bA/drYCcBnl//LeZg== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MW3PR12MB4521.namprd12.prod.outlook.com (2603:10b6:303:53::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Mon, 25 Apr 2022 03:46:00 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:45:59 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 06/11] selftests: mlxsw: Check devices on provisioned line card Date: Mon, 25 Apr 2022 06:44:26 +0300 Message-Id: <20220425034431.3161260-7-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0102CA0066.eurprd01.prod.exchangelabs.com (2603:10a6:803::43) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 9463f29b-b9d4-4757-afd1-08da266e1cd3 X-MS-TrafficTypeDiagnostic: MW3PR12MB4521:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: DIxFtuNlS+uBiQqr2R4NBa0SL5mb1DFVhp+2W/2IH99byrJ2eZFE6AaQanyHA8Kzg4JEWL/iuult8mf31YexU7LFaTkFcsiEL8/LippA1Sc2sG74ALQmyrmsrKcAuOWSvMQzQcCBSdX3JjE0MtO1/eTIFUocXGzNaLR9YMVI0S1+ed6dL+exlak7cRxKJVRZy7btx/v8up5xhrJ9vUnNyUBBJ+ofyFHAOc+Zr+SnWirAVOFMJKIInyPpWFGoNPrOFIHXYgreI4wbXyg42BUcqMidHoxxGI2OH1kEj8k+DoF71LICnOh6cJ5fr1835WP7vh0VHesiJVK2r/dUT0sgJpPuAgnWrzlRa3aJFKaH49WvTs/HDXcpdbhsEi0xyL00URfMnijJg3a/kwnVGJ4IDu8GqcOGnZa2EVa3XWxR0TJdtdB8D27a4IGt/CIVQRAXTWU200xVK8lxpv+hTr+Ipv8LVYFKA6lgwtxNGSXJLbHdpKaXNNuDvbCtYbvFpEC7x5ocvc0EQEBgg7l85ydmDN8QvzxZc58iakFSNtilSciecWL9cL/FjBAe7yAi2OWxU1kL7nSYQT6g8RF8dD80rTHeGYP4Y899Re0Qa0cEanMmzXrgGGsitRyQdkB3+FyxItZPlwTM6lcrzsA1ffhzGA== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(4326008)(66556008)(6666004)(2616005)(66946007)(6512007)(5660300002)(107886003)(8936002)(86362001)(2906002)(1076003)(38100700002)(508600001)(6486002)(316002)(66476007)(8676002)(6916009)(186003)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: Nf9yRA/AyWfVvaP0lVGtEKgUxO0+AxafkTTsM8UmDQh/qCkBTWutnQM8FNmtz/vyEqn4EUC7zmLSgjnzSC0yTeQBhHBzUR9jxBzYWBgFltJMlRQR1M3jyED2eXWMLYTfILmK6S9VNiJkKTs+/CiF+RBcJODhRlyVxUUNaWUwDus2Q5bZ2zh+UC1P9vlbB6O/hRmaOEkow1YIERNRIEDvwxgi4Tp2vX2JNsSKzvZQXlCvFUkpWNZ+LcNjAeoMKp+cNWx/iU/1w9PEUU50wSaBnlVQmFwsFcqyMbOh1M0egdfTQBCH26iOqqM0VBDC9MR2IJw34lSqHREiv99SG2GpPV2P5RZkSuGx6c7rXa75HtlhiZMh+SIcOlZhRAlZfYSUS4Hn7OOeZImclK+gT8kvvnL3h2UWUBLyAlYJ19XHwY7Gku8v83DE0A5u+praN+gMjmJUXIVL9mOdaodCmQhBWs3JZpwQL43YOc8whk/mYYqxvRIiHGISGQ3fSBFMKkKyM63Z9y7RXIdG+5PMIQR4IC8PSPOZ3DYWnVJSXyD+elnHx9Gc0sWtEfuL46TIB725HUI3BkTgV0gt8bfNw/bAYLUUDWmNy6SwTchOO0Z1cJz6TT/D4Ddke5yMK2ACBPgOcBTUUmi8TaVbIDUKn2lmZBUIzv89kbZlzdI6shAf8XRFT2hvTT3v3LPEGiT8sfTpZpY09m4SNL3qtgSHqj9DEAlmkUp8qM5+S99ZgQZpj6yIAdR+toL5u16sEysGZPpV0clUw2YB4yN82hYjj5ZWe9UnesQZGTR+eo+vs0Ia2yn/5sfi8OV453wVJlhvW7kVM9GwnaO32F+PEvQVR89ULaCVUafZw+0i7a4aJ3GwVxWgzGKnku+qp4RiasGnipMLYEe/S6uxhlycBXGv6AxQK3d0FZ0pEqZCsmTCN79tMW/EuUnCJ8vVeeQ0M3NWOsmSRA6fLCLjF2Mnelj+qwGc69RvgDyTrciZ8Bm+jzv7U566F0PA7pU53Y7Vx7sluLgLctqDMA2UDcqWF+OLKM1b35kBN9WXWsHrQqwSBLjLtk8AxeYq1541wp4yYMlYkglyzuckrSausNr+bEJLE6/O05xGYTiAuxGZcKDfqotWQpfmPDWkshsJb2OS4NJk5zis8n7mYzqhz9E03U7rsyqp3/AUJVPY/lTy9Q6bIG1LdyYDFrGrzTxPqbohWc+CqtWc6PwpC3Y9QRQdUro5HI4TVeHhhFKIj0HPlR9R0YyD7H0V1jNnuh2IMTcG8+LFY/5x1tsG117nx9tr+KCp7xdliZ9sx9ajX6NAsef2MzMUkgbtWzAZJTOiaocYI4P+Xz5yx4vV4UfW4gqkwHv9M+QLJSfMby6KGfOBbliAZC1sOk88q/h5cPg9n+h7PNv8uW3AViEb35f2kbK7amki9yZ3ap55muFNxpzSAJDDw1/xDzXVYUR+A+J/TXglNMqmVLyTpR2LbQh4zK7Tni4VrBQRlllYXzyP5AjWtelZ+EaHk8ddlMy+XEc8w5qdjTf4AuY3GKlSnotg9T1MzWGYn2JEwrVgwVrrxX1XpBJYnQAV2c4/X1G8fMNIlSx3BjKRQjakOVZ7Cjs0yqBtxUVavQV+kdw6e/QQ1E1QmYHbYqBz3VUqnU5PVqiosq6spcedbcUWn1Z9FcCjyho6anLXvAc9hFP698WW4QBVugk8JROd1P0KQ2qle2fYBODW/oVnCp9gCPMo4dagI/kO9oN5SYApBg== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 9463f29b-b9d4-4757-afd1-08da266e1cd3 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:45:59.9177 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: uEka6NVR3NofN5Rb8lNhO3lTtaOo8YtLR6+arXDrg9oCMi2EsUq/25dkASPlOOx6z4V78l3gGme694AqEkWTJw== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Once line card is provisioned, check the count of devices on it and print them out. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../drivers/net/mlxsw/devlink_linecard.sh | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh index 08a922d8b86a..67b0e56cb413 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh @@ -152,6 +152,7 @@ unprovision_test() LC_16X100G_TYPE="16x100G" LC_16X100G_PORT_COUNT=16 +LC_16X100G_DEVICE_COUNT=4 supported_types_check() { @@ -177,6 +178,26 @@ supported_types_check() check_err $? "16X100G not found between supported types of linecard $lc" } +lc_devices_check() +{ + local lc=$1 + local expected_device_count=$2 + local device_count + local device + + device_count=$(devlink lc show $DEVLINK_DEV lc $lc -j | \ + jq -e -r ".[][][].devices |length") + check_err $? "Failed to get linecard $lc device count" + [ $device_count != 0 ] + check_err $? "No device found on linecard $lc" + [ $device_count == $expected_device_count ] + check_err $? "Unexpected device count on linecard $lc (got $expected_device_count, expected $device_count)" + for (( device=0; device X-Patchwork-Id: 12825244 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 76D09C433F5 for ; Mon, 25 Apr 2022 03:47:05 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240818AbiDYDuD (ORCPT ); Sun, 24 Apr 2022 23:50:03 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:42850 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S236822AbiDYDty (ORCPT ); Sun, 24 Apr 2022 23:49:54 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2046.outbound.protection.outlook.com [40.107.220.46]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id 2AF42DE99 for ; Sun, 24 Apr 2022 20:46:09 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=aj8clBY1B/5Ahz5TdBx7AdtSrqV1KTmc5ydkBJbz1ewaLIbDAKGKZL0dOEKyuSUH1FJP+mdKhreVSnnBsWqXQU2y7O7mfHAP+07pnYJZQiWUWbiWrFu9Wa3LN7QvFGrHrc6QfFDgTt6NIOdI6zoxn04WgxYFByXzDr42p8laix0C4L6gTpnpnUj2T9csC2gf82/sOJ0brso1PA3em19WRLgu6W+Y2pN6twZYWSaPBzD68HhLx44U5dxmthyhhIFaEbcI3qgSDakn/dSSW0TWkOgXiNXdzA3RKz1U+nf5AZiN6o/Dr6p2n+APeT+WlU6rn1AgAQvJbDg/HVEWbsG4lA== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=+4NoXsvHXpmEfxxC7ZIWqQpNjM7Ypxv8++LjHaLWJI0=; b=eYyl6CpdZrHPkj2m4QLZKpBZmuzY1zLqiMPn5JkrLzl8lfZuOGbjYCDj37cFIWdtq1Z0CrwRsueLl0SuCtYwbEFZP2LHGTVehP1bhCOUeiZZVXuNV+NSkLu5AMAMUAPHTlfpF2kKeG6NktrbUW07rF0UyNKGIIY+8cIIeG4nomlvQWFx1YhlaKTXTF4GzMQPM4ReYSXO60U9ZEpcUCnUN0mwCNF2OMk2ZHlTCViqp+3Te7vf2rN3X+TX9uNyv5gI5mYSTqm/PArk0flzeOq9bVyTD4oUCKMuxpPFxYSPmIDioSA/ZnDAv9iAxXJ/LbtK0lBfO6h2n/GSE7pnJ5Shpg== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=+4NoXsvHXpmEfxxC7ZIWqQpNjM7Ypxv8++LjHaLWJI0=; b=tXR9qurDxkuTBMRiyOz7eCDfmRLt2sjwbhAx1im0dquOHl4+OABd95q6ao1U/TpGj5/lJDMSlfJ/Fup+Y0EcBhQ3NJA+6VTtZQ8rL/xvxqtwjy37HbFVRd0casAviHhvg+oifQLRNriWN/ipa1DpPTgk1KLH3Auc4bSOTRcCmoUNmdWAGYr3jcHUN1qY7McO7eD/S9b/3j7lOrLRiCiKVxByhpUdlLf+gUunYFF78wrQj9/OAIL5ZOVKrxNabAwEaGrqywvspDVJl5ysZBt3+kyVTq68ldhnoOQtVnFy2+8/7J3H8fgvR6jfBeJHYHSWEqWAZt4OUGK27KNALAImMQ== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MW3PR12MB4521.namprd12.prod.outlook.com (2603:10b6:303:53::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Mon, 25 Apr 2022 03:46:08 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:46:08 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 07/11] mlxsw: core_linecards: Expose HW revision and INI version Date: Mon, 25 Apr 2022 06:44:27 +0300 Message-Id: <20220425034431.3161260-8-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VE1PR03CA0026.eurprd03.prod.outlook.com (2603:10a6:803:118::15) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 212829dd-ba35-41ba-87e7-08da266e2193 X-MS-TrafficTypeDiagnostic: MW3PR12MB4521:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: jUhlPJYzuxXvE9KfbbYju+0sCzEOmLJRfmzRleOHJAUJEzsiebmqgMn2fKK0OQ2GPkki5RcdT4Er9W4gmeIOnAutx3XNQQWH5DPGsyPzeSbQdo6l88NhVMt07a5D1BC5bQhIJq3kGAVx9aQGuO7mrZW10zxIswivaagYSJOoUEWDYD/m1m2T+kyWFjbHdiYNX7hRCCcwegXd5FwYjCc54FtR3OYuaudtOuKbFVdJZtCCVuT2ISvqKuZSQVR2XqgfIeQlF8v4hkZ9rOO6kJR7bQjRoxJXuzbuA7OQyiw0jy7YZghhswBXpW4iUxaa2yKmM16dPjCyEr/SVuaDzkWSI+XieERlregS1aSE54MjsVyOwCJT6vGYW9uJ4yuTMk8SoG8LuPw5sXnIhL5afUmSnjxB27vWoD5qI3JOJ9cgNeSFZa1lQSORrNzJwz9HMH1J1SNtRmDtjJStusLsJ+nFFNo2BAsnuKLijgJ0jaeaLqe5JOuZrNBs59p5D+WwyU6EOn32rmxGxuxPO7SBR9DZkZ4vwejLPm3ifckbjWchCSlHZb4SmQTT2am6+CdacFtCMeH9X22sgSm0swPb8Ol9cUwHeUX8+CJQibBuPcg3fIRwQxHaIf6/bWZOifNZrQvBJ0ZdsxbiuScKqwGxg9tccg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(4326008)(66556008)(6666004)(2616005)(66946007)(6512007)(5660300002)(107886003)(8936002)(86362001)(2906002)(1076003)(38100700002)(508600001)(6486002)(316002)(66476007)(8676002)(83380400001)(6916009)(186003)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: TLzBFlAxEZ/YnciBEOE7lKa8spjh+wP2v8dUuzjSzNJ4D9ElkVgGvGH03iI2RAu07BFk9GU4x5cEb/3y9gu9+w940HKQQK3UqAZt8ujfnhK3Q0ksgoBw+zWSResYpAcLLsV1zCw6m2HpunWDh70P6UyS1GocTAtbGCqfEgmMQZ3xxC+ZVPe9IfeaLVMOQPlZ76GxYB28PYDCv9fyFHY2Mocw/qLzaA6Wg/CpfLLM2EO28Eajor8R0x6vZtZLUBfzwAV+1tWh+DqEcs0NAsm/gnCaTsvuEz+7QcV4g9FXEWIUverwj3XSOHyZuKMOIfxbFPCLbHZJy805qV3T2/2vawsDGU1MpS7eOYjz7q75BCmdo0yvi7owtcgRDo93mvKHPd/P0O+tLJKr0Un9l97/DAGe0K/IbNAKTgfNaFQ9Kl/8LmZ1Roo4cCCyjhMO0R9JBs38TnEbJLNF4vt15uOqSZ7F/KW7wuvD1kZTKiOafjwWsDstEWD2A6/a2pbOcVRKFBlE0a7qBXl1/uABJi7CkcPZotda6DfuxYxIbCWTesObBLJRaSrVBVdyR0yYrXEBLYgX5HtjwIovFMFDc/lnaOCaFWnYRrUe+hlSQP4fzpvnZ46dUXVaqtlJxRsTrpD6tsut9PYJVYV7YEsUwbU/IMsf2TkNXru4/DfHoVucb4/+PEWv3zAqq6DaTTyF2ezz+ibS9SG6YGvUrtbd4Tc2AYRFthvDCV+es+8MtPdubcfoxcShD43gheilszJ+nrgpY2psJzgVpSzgSCwSa2x9Bf2YjkuzyTyEMMBbIBGBuvKK4AmQw/0vgOUpIC/ER55kGGZ72AF6Tq/DmmDH1n8GJybzatVr8iESUK38hAgRYa/sDnBxuNJG9+T0zFhYe1MBNLWq9QOKMz6rGeuE6x9OTLrCs4DEVOrTRHzJyqM6mGGFoSaPr6kKgmvKqdg246/Ngo8cBkE8vTyGjlOwxkqRsNATuO8ArITlrjvVFbiM3B/20YVVvdJ9FGkRhTPfg1jaSPM+JVHdmEU1P1ZvTJ5gTcaXuwmEUBFW7f8zmXdjil0xFiOBjtWXAaCfTTV7xgB3+fDtGwZRpg+e+3HgDu0z2C+7HHz6axez8dRHVgULQq6ZidVTQx9ErMqkNINabLemypVIGoEaOK1///4kn03QKVxKZMAhPeeLshjEBLkQfwyVHwDaD4uHT/q4lXuHfM0ed5VCbjqFs/IoIujXZKr+/axR1Lz5RRIqe8fsQ1Q/E0Ve7DHUBf9UfmxKau3LdrIOnIY3yc5y08RBgKaqfGuHchDcwQXvtA3SUyMzXIeIB/98PmZ6ywFme5T4K2mVpEK5ozb8y2Tsqmb+XhF1FJZUXIbn9/fdcWTi633ojpf9OGTE+HrsS9yAQR4wlMkww2/gPCSh6LQCzeVCQD2SRUInnpPm4B8EcopSMMBWk0R3bOfvweqaAO6Qw1BANwyEZPgNwFZrTT9YKtRyQRXp/ISNTEp028fAAqpMuQL+vXQHzR2RIAssfOhUqH2kEh2jxYSDchgctlgBr70TnXkSijpCUew/ftsTaZeAxv9259DJlFjnCYha0Efnk03ToPvu+s8G7jDw98zDCR4iS5HdLcHXPxK80UP7YWX/S3PMCCOc1pSaXbZWk/khR1ufmEH6cp8+okWKCaz07fEGmGsGASd1GgWFl36cV2jVAtFwKm+9oSR1+Y1e8kZI2sNcribLG3fZ90iMySYJe0XdwxOrhlPrAg== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 212829dd-ba35-41ba-87e7-08da266e2193 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:46:07.9327 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Dp7C6RDe0G4eGwTnIpEYe79hzVr3SydxxPZvqB9KfqVKmlEbkywYqaOt5akm3SeyQGfIlAIMLQn+08voSeKF2A== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Implement info_get() to expose HW revision of a linecard and loaded INI version. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- Documentation/networking/devlink/mlxsw.rst | 18 +++++++++++ .../ethernet/mellanox/mlxsw/core_linecards.c | 31 +++++++++++++++++++ 2 files changed, 49 insertions(+) diff --git a/Documentation/networking/devlink/mlxsw.rst b/Documentation/networking/devlink/mlxsw.rst index cf857cb4ba8f..da1fbb265a11 100644 --- a/Documentation/networking/devlink/mlxsw.rst +++ b/Documentation/networking/devlink/mlxsw.rst @@ -58,6 +58,24 @@ The ``mlxsw`` driver reports the following versions - running - Three digit firmware version +Line card info versions +======================= + +The ``mlxsw`` driver reports the following versions for line cards + +.. list-table:: devlink line card info versions implemented + :widths: 5 5 90 + + * - Name + - Type + - Description + * - ``hw.revision`` + - fixed + - The hardware revision for this line card + * - ``ini.version`` + - running + - Version of line card INI loaded + Driver-specific Traps ===================== diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c index 9dd8a56add4a..b5f5b31bd31e 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c @@ -834,12 +834,43 @@ static void mlxsw_linecard_types_get(struct devlink_linecard *devlink_linecard, *type_priv = ini_file; } +static int +mlxsw_linecard_info_get(struct devlink_linecard *devlink_linecard, void *priv, + struct devlink_info_req *req, + struct netlink_ext_ack *extack) +{ + struct mlxsw_linecard *linecard = priv; + char buf[32]; + int err; + + mutex_lock(&linecard->lock); + if (!linecard->provisioned) { + err = 0; + goto unlock; + } + + sprintf(buf, "%d", linecard->hw_revision); + err = devlink_info_version_fixed_put(req, "hw.revision", buf); + if (err) + goto unlock; + + sprintf(buf, "%d", linecard->ini_version); + err = devlink_info_version_running_put(req, "ini.version", buf); + if (err) + goto unlock; + +unlock: + mutex_unlock(&linecard->lock); + return err; +} + static const struct devlink_linecard_ops mlxsw_linecard_ops = { .provision = mlxsw_linecard_provision, .unprovision = mlxsw_linecard_unprovision, .same_provision = mlxsw_linecard_same_provision, .types_count = mlxsw_linecard_types_count, .types_get = mlxsw_linecard_types_get, + .info_get = mlxsw_linecard_info_get, }; struct mlxsw_linecard_status_event { From patchwork Mon Apr 25 03:44:28 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825245 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 87354C433EF for ; Mon, 25 Apr 2022 03:47:09 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240856AbiDYDuI (ORCPT ); Sun, 24 Apr 2022 23:50:08 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45162 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240689AbiDYDt5 (ORCPT ); Sun, 24 Apr 2022 23:49:57 -0400 Received: from NAM02-BN1-obe.outbound.protection.outlook.com (mail-bn1nam07on2086.outbound.protection.outlook.com [40.107.212.86]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B6BDEE0A3 for ; Sun, 24 Apr 2022 20:46:15 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=IGKh55XlnlCsJH84bCfnvTV3DA6dr/sTrlmJLrL9jKO+oVDjFPccfnYddq6/5KmSDS6p24KB4uax7WNab8EXGiBkeJTIo/Dw59245qDTayYyC1KdfCLC4JuqQoLazRjdpxla6NoGwtLmO/6vBKovCC5NXXv8Nn2ZnqEn2x7OVJ/JjU3fBkR2Wp3OJH0oXlkLWniMtfD78FKBqR/9zsZTGAJWbU5iooUIk4cr3oJsH1nuDP8LW9XIBSSV5A6FAOn7+KtaAG6JLDg7afknYoCJ6/91GUYTo9TrakF44jSHxd8TwXcyrsvv47WbFsamA0uNy2fi4im0ensPEu6ZQXKx+A== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=aysSTa+oHbqsyemPQnm4QtIeH9JQS2CS56tD6nIBd+k=; b=CPngSxwBTOWaAnqEH5zlPzSCKoJ/IfYhOpupfaRALfNkQ+nRy6cVed89k+KczcSL/WIDz/2PhZRhvRn8Eqs187ZpCNkkn5NN/x8u2qJ2fH0RNgUz9PXkEHRTwaOAUh93IxGRcm5AlD6kNU8u/oYk8zno0d8Hr1xImoR1PuQVxS0DK005WVQ5YXHw5TSstNVX+0+C25TQmD37n94rx4kc3KARJmAoe2vHw5h0lfwTzvA8NMJU+e+2n0xH7+OFBApcGBm7j2M9L//srNSJXIgKSrbfb2kASHRWeNHEpbj8IcsUdxEc47t867VitYAAYCvayLxYU6hqm5b72jyfpq7Y7Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=aysSTa+oHbqsyemPQnm4QtIeH9JQS2CS56tD6nIBd+k=; b=nR1LprGXIOfwvcv7lD72jeMSI4uFfbRsm0JJYAZeJloUH+ogWz2F7qnyt879sfXEaQuGjlBpnOjaldgOQQ/xEvn66FyF/k93Y/mYVEXxh78nmUbbU7KZP11DPGy6AYBKmK0pxum7Ef2/GEOt22P568uKnRqdO/q3WGHTIB2LEhzYFP40AtA1I9TDFvBNJKWWPMf2vMdzhaopRSs0GQwZG73dyLdgemazsJSV1Zd8Q5ge03g1ieWutUttdEjHJsohV7+RY94tneu6xx7QWgDrzud8dJ8n/hbfxEwq73gArHSGUUmXhuVHPpH+dqGI50ga5blNygVohHre7On2IuuQ0g== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MWHPR1201MB0255.namprd12.prod.outlook.com (2603:10b6:301:4f::19) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.14; Mon, 25 Apr 2022 03:46:13 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:46:13 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 08/11] selftests: mlxsw: Check line card info on provisioned line card Date: Mon, 25 Apr 2022 06:44:28 +0300 Message-Id: <20220425034431.3161260-9-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR07CA0262.eurprd07.prod.outlook.com (2603:10a6:803:b4::29) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69f8580e-bc38-4840-0513-08da266e24ff X-MS-TrafficTypeDiagnostic: MWHPR1201MB0255:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 3a1bjiItnjmzAM5vg+elBngUUsxXAvmtkzofD2tJp3GVyOrMBZrUHYDEfvCMfwMSkROGFzSePMjosYjaAIhYcjyRksEs1otBeKwhyrGOteyEu/wUZAueSKsLkG/b74Pxpp6fIz7MsGlCgFQiBfrKne1aehZ0dX/J4qj2VOB2glfywxhGV99rFPeZmpJ3vIdmpf+0nBbZjQ2hDqLxFG4gr6sY2uSzbm4q+8ZfuD6y6RcWYIg4wAm9ThRwrXF7oxVEhWinQSHy+B8WJsA+NkiY9h3HPyEETF+0KeKlfm386sBc2tsuReE5czrbNvCY2I0qRTLqfgNFJMKAyDPUVVZ1iMASpmKR6rReX7dcU/Ad1/luz43Vav9e4vzJmwfvscwzYQTO2r8Q4fpZ7Jf+K2GY6EiqPneRbd4W+LYlPeR8W3GFFzxks/uG7tGg0Mdlt1jFLQ1TRDRODx/+fA9TwqCmZTnT3eIIyh4iaYC4rb8BunMV2iG03Q3p+tVg0YZaSrgUTCe7LMTTNXA8KiSvVl24Nbi3YHdkjIyBuO+BdqwiTtO1ERkpKluaLUkNt2f4sLEQHWVQomZqiux4WM1zYnHama5+tuCVhLfyIcopO0OrcpHX4BUmn5OgA/n6UfZ6/6vkKAVQhESKgDEICjmhJbxtOg== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(4326008)(316002)(6486002)(508600001)(8676002)(66556008)(66476007)(86362001)(6916009)(38100700002)(66946007)(5660300002)(6666004)(6506007)(2906002)(36756003)(6512007)(26005)(186003)(8936002)(2616005)(1076003)(107886003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: tTIXBvisj3uKKnyboZZxIH8GAJGHpQcIORYtEtIbdFy8rkDI8QM21d3i94IMtvP2H2JfGcf0f8Dy1Y0Q5FbJxuvWke37o9j20uMBsOC2ZtBzwRkx/SMfngPC9COi6tVMhEXlAsPw2/9PTtyo+yd9fsAhb8vc4kT8BCH0e0AGhnmspJGWp6a8F4jMb3hRjyRsbfHZ6sJyhCFwYQud+4th9S5OBfZtDDB0ImF7hWxU3ra08glxIfViOHLuKJRYjgZ40NGDoFOWajrvS0W2xqYLlq7OJ0wU33nuMLoqvOgGeZLwAjfQsncKXowqn/HbUJnP+ERAJ6bi/IlMW8CDUixnIRPJaK8vM+7DQ0nEushECc0akE7zWQSsSBcwOn73N9jk2o1eiK1gZzZLqZGotpovtXVbfUp5l9JYMeSdd7xUhKzoPb3PUm7cgSpbbb10w+KiIiLQcO8SLkhGTdMWoF/gLKAteDKKtcTxiUP61JTSVkg1kj+MI3ZXCE9HMbBmfGDpy7ovF6d/ZwwZRZgLMt6QtGyvDcw4XVh1TTdT+jl1W3C+QmpHlUqKaAqEV/oJYLSBtKMls9le/19znjhkbNGSxCGGVEdb1ggoHYxcy2vxd1M+Ev83KRLfk+MPRG+obwEG+shZ4RSoxSaQvFIULcmAoRrZcChfnjqgtNW1oFbFU1SQU5Wi5wCS/e7ZGWSioVDZQxWrc0o7Es5uTYbB/z9GPnKGaEtfNe0sPs9L9I3vdMEsHg9rNimsf2OVD3QyzMrJs7eoKzIMJ3BwQBywcVbqdDBbY+q2SFB79ilpyrYWnp/xJ7Bpgv3ni5ckZe0Ymoyunxlq9XaYb/8GDaj+CJ8gkRdiU6E6wYyahKSZXRUwvTzWWLwZVw4iaFi8o78jBN8TtN6m2SXqzu46/tQ4qfkZQAPpl54AFweypwSMYvmQXD6XMVDumfvtR+YHoKa7mKFAq+lelIpmV+uHJPU7kU7ToaYIrAkWI0crJfFej46R4faoDI0KzuoU9pSaYwiBbKdQHE2n84f7BkS7ivEOyEBb6N/lANW9mKwGj9OtUyoMSy7dkZwJZKJ8TajGi0mD/I1s5mhJVYd33/iSmE94MUa47yoImqpKA+9LAf1WutKg7psReFofQWNn3wmPhnctYsPWBjVWv+iv5/Tjfa1oh1MRKv+DOwFqDDPbCTfYDHQHir29uPgn/weMA/igUxEgHzsbDcJdOB6Wq6ruw6Lfp8d6lUn5IdwcCPL/1OgGlbjsGfaTeYXMwnWZlDzVV7p3eh9FT37/PPmfUe+/j8aWolKrxiMICuEQbsT2TNtRQLuH1l+l2z8XXDioDHiQ/PIjaICFIOCPbb32O4qoWsldasDUc/lZ0F6Owqn8SnBuTgVhuhdhO1H9LH+eeNbKv0i8cjcEJcVVzRs3fxnL4BQrG2wMS1AlAfQ+2OBzG0Tv72LN2+fOU4zjHJrdUaFYhNbG12EzSZnKqvdDXVMv4DRTvN0gv/yVqtanU5B7rnfDDO2nRuZ9+c/zBNRv61ze/it4GdxsduLy13W6D1DFh1jmnLuiXHG5BHSQdbd9NQY/PS/oQO2DoTKmv/0Y9qGyoWA7Vcksin9K0r1lbE747zXrLn4QGnZMgifVRto4hiduKz8p/ju5xDwbZsXAhsYrcvHLP3OiojevoAHoHqEtRA6FtTJiRxovuAWc2IN4fyYGtYex8d6h/dLL1yT9IjJZo7+w7wdoxmvgh0nvc/3hNId/B7xKVA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69f8580e-bc38-4840-0513-08da266e24ff X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:46:13.7640 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: UDvahSaRNiQmqCpnnwB6D0q+JfwY5zCmBjCn8p8zLjJob/jJWledhHc9Tg1JcSRTMKNQq4pUhPdwxw3s3XQSmA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MWHPR1201MB0255 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Once line card is provisioned, check if HW revision and INI version are exposed. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../drivers/net/mlxsw/devlink_linecard.sh | 17 +++++++++++++++++ 1 file changed, 17 insertions(+) diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh index 67b0e56cb413..04bedd98eb8b 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh @@ -178,6 +178,22 @@ supported_types_check() check_err $? "16X100G not found between supported types of linecard $lc" } +lc_info_check() +{ + local lc=$1 + local fixed_hw_revision + local running_ini_version + + fixed_hw_revision=$(devlink lc -v info $DEVLINK_DEV lc $lc -j | \ + jq -e -r '.[][][].versions.fixed."hw.revision"') + check_err $? "Failed to get linecard $lc fixed.hw.revision" + log_info "Linecard $lc fixed.hw.revision: \"$fixed_hw_revision\"" + running_ini_version=$(devlink lc -v info $DEVLINK_DEV lc $lc -j | \ + jq -e -r '.[][][].versions.running."ini.version"') + check_err $? "Failed to get linecard $lc running.ini.version" + log_info "Linecard $lc running.ini.version: \"$running_ini_version\"" +} + lc_devices_check() { local lc=$1 @@ -228,6 +244,7 @@ provision_test() fi provision_one $lc $LC_16X100G_TYPE lc_devices_check $lc $LC_16X100G_DEVICE_COUNT + lc_info_check $lc ports_check $lc $LC_16X100G_PORT_COUNT log_test "Provision" } From patchwork Mon Apr 25 03:44:29 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825246 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id EFC4DC433EF for ; Mon, 25 Apr 2022 03:47:32 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S240833AbiDYDuc (ORCPT ); Sun, 24 Apr 2022 23:50:32 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43138 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240827AbiDYDuH (ORCPT ); Sun, 24 Apr 2022 23:50:07 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2072.outbound.protection.outlook.com [40.107.220.72]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id D645B1D0EE for ; Sun, 24 Apr 2022 20:46:21 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=Obe1gsj7iojCE2JuylW1qGUYMUbaIbNqXEeq0U3WbQzWF2Vcax3UxxZTUMOFmyNaJQibwF4W+8pklXGUxOvko8sAoIil4vcdgXlJzlbZqUT/hPVOsMdJ1HShW5tuyjZAhb0tZQCUC4/TEq5diRqPk0GmRuv6tzwv//gihsYjeeHYuwfPWhvnqYU/huyXQFCVGZcmd/v6xKvhxq18jK4RdlTRm0pe7aHrc3JH5RvJvnY1CmDayeXTtGQjct4y7OcuqdaQeyxqwkhDzERcptmG6PySQhLhaBMlLoeZumfS/N7cgdQrLcX89lBOnuuWxfmzS3CpemropnTcG58azhNTtw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=bafL/T6A0chCxGjx9gRQqutrDMKvXgfBhJUYg43wkJk=; b=kJ0VajN/UQYvliQjpwNoO5OHgGZjGS4H7Q4mmAUIBT69WUqIeZhcSFInDPdqJZ6LFv4kfPWzaQMA2N4uvQSrL9Lh7/yoOv/Zaar/vD/+/RmH/XD/IgolOwyE4bfi6SnTLNXttmEDCEjW1V8U/xaYyxdZeMKq/E2RHLkyBrOcrqyrzQxhnlVE44SuO8xYnm+0bhN5mHAfX/6xVtiqP9C8pCrGFNnz8HqDtHrYbHjWP2NJFe5VHoaMqzA2RW25PzL9tK67OEgnJ7tqc76Zl8LZtsn7ksHM6QwZmNzBQo2AowQF4StHrRXiwxVZO2j5jVjjaD+TBIpKFtAIANqc6PCR9g== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=bafL/T6A0chCxGjx9gRQqutrDMKvXgfBhJUYg43wkJk=; b=LoDtARmAEDFUTPRF5uaCJIcAsSe3yDnI4N/+FHq2OlDNlY5rE2Zra5PBU9YTLtpOh/JIp7V/QoFR/gu1L3fm7ylRfL2uZ+6GnRuX7YXcuSm6N9N5bMWSfXjKxpbGufX5xpAUXp9h8qkVKHEQV7B5ZUcolxtwoL52p1bw0gG8r3qnocCgLOoMfkD3KT3ld5wL5DiBUxBACIrGQ23sawdf3BCF6YHoVvCn6u2oJVITmSVhz1XwB4i4VISKy8aEIKPFZSuFDfHogw2S/Wll5cW2kzzbBR74hssTMPBbx6FwaxsrPGYtJvEnNKIDPQ0+Ld4AqDWjq2nOytwfhp2YhAOBWA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MW3PR12MB4521.namprd12.prod.outlook.com (2603:10b6:303:53::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Mon, 25 Apr 2022 03:46:20 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:46:20 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 09/11] mlxsw: reg: Extend MDDQ device_info by FW version fields Date: Mon, 25 Apr 2022 06:44:29 +0300 Message-Id: <20220425034431.3161260-10-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0102CA0085.eurprd01.prod.exchangelabs.com (2603:10a6:803:15::26) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 69e36f8c-3436-4c6e-0a08-08da266e28eb X-MS-TrafficTypeDiagnostic: MW3PR12MB4521:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: S4D+yj6EmO58Ltrq11YUopVCpo2M6gYAE9UK9/lTKxUHGvrZwwj9jLIoL0ftLmGwMn2RGR2bGMX8+lcVoraoB7V9+kg2lKdgaM75Ty4PpbZowWtYdhjx7u0Yo5NTthdhLvfvLv6yKxK83mLVtpBIa/orK5h4tLnnxYPOgx2ye2fh/w5JQtCAEP2MKTz9GEHobLPQb5K399tC8sHWst7gEKd5JoedZtEOOKxk8LfuB7shfqsYcuQvoI7CvhzlAylgB0Uq2ekeiXx7b/G6SqBSJfwgXRJu0Hsisvr6U/1lZnhGnePVpavtzcEvrRRMDyPeRBD9qYuPoMsGgWgxio+6dvR4pnSj8qCNYOHrh+JhRgxpdGOlLBtCnmfxWt+A0ilx9Ati7OatLYbB/vwr22/wdOO6/QrlpFL8C8eQRJmQRPH0SxXnawNwStY5cT2n1V7G0vo/Gv+efUemvIpbysvT7ySliEpGTPvaTa2xIwxvB4tkye/5pJYuwo9jHFAG/O6dmLuX6BshOijLiCzXDi+pT/xKSG/Oa5eRDfS0SqKUpNBSLChGzrKw4+w5VWPXnZhfqBPDy1YE48uns8kdjqsCI0wd1vutu+dIS3yj4c2tFbK385tcKVjL95fXqLlfL9w+PYn1GJUQyTsNd2pdhOk+eQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(4326008)(66556008)(2616005)(66946007)(6512007)(5660300002)(107886003)(8936002)(86362001)(2906002)(1076003)(38100700002)(508600001)(6486002)(316002)(66476007)(8676002)(83380400001)(6916009)(186003)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: 79FyOTXtcLh0zlXU9Eo4+DlcgAVhvmHPiyNFiwy9pSVIb9othr/n53Uo+WMfd23Frgy7/zMq9X0sUP7PS2YWESa6Epr+OiAk/oZm/uwQW2qm0snEZe/DTuNk90NgP0bcgUXhpBbh5QooX5AnHUwEbZJ6RiP3Zvzli2crKd7HRNyEg9K1SDXfzbBnz0xDokH1Vl/y1WfTSQ1Gz1RiUYaKsR5Swcrg4Bf9cCHUJySjcRAK5uHsl+pYv+BWwNqGxW4hB7ao2AIoOsYtWzU2guQ9xhpsaajaSyCmjTsWhJlOyVkuPRnl8zcYSSFsl/foC9W3FV/4gqWr2+C3EvQptCIXZNTO1NYBNNuawHvcDjZNP4a/8/1cMKGU0Hft6gSptdZvJwcxdRvGE6J55eKgVTnrfsrE+vgrVI7yIET/m8G8UPH+55vI2GvdlaImqdNKnJYJ1xs/0y3C3/sT0ywiQ2aeTQh+Co0Lzpqw+GUeYV5KAVw/N/EuybcRNzCszPkP2JbBsOMRr6XSI7zwUwqksm8i65yBi/AQi++7XYkhX7nBsTlgZv48bZ0myPYCthWlJvkcu+mM5H+6IlfTIlr0a6i2hU6/Pek426D8pUEFQQFSQsXeTA82Z9vcLCCTHeKGfdufcW79345wMZFBJvgQX9sMx0vc7AAKDQ8/5Zv8w5RU4gh0sOyyHNAbWm36w62r/ZJVvNP049Dtng+4cm5zST86n/mvRp8sZe+x1lsCIfVEh3lzDEJlHU61lcQfJxDaMlxaqCK5h+xKHP52SDol0jBI9RHdkr+YpPsWxY8iarOjrG6uWNfAAqarkFjimaqax5GGyp/H8Ov81ZW358wGtqbVVGQ9wbaduI4saBAGaxsQ8JNCGYc5nWTbHOczUgLjxIEr9qCerf0y6zozwDKRDhg/EvOuZXzxSh783UQzkZ7ZWm6MfJRSWW+7cUWjGRODhw78llmb0tewdQfqUxM+TACRaChoiHiMnv/rTYU3CeU2OUc0JJC4l7E5x/Rorj3X4wfTRlYyUY5wnrfVPT2GGcIuuhGF7rMWj6f7+7R8OXdSWQrc/sJ9fcxbmQHd0ADQSuapjug8sWp6rBrEzhdEP+QpVeuR7BsXu/rbsCDqIKZvrgl2PW99GglHZyh1ET/aGdkPKI07lQyoakgeoJlLpJwawsbZf48UMldfk7iCZ/OYChcOff5YXSQWFHyiLNftwOcIDD3Ah5RQLkvtr4XEkFPEHt2Z/IuGYa71K7BkF+c95FaRPDniCRTXRl9Tv3gZspJc5MFSbM1iitbeEXqjy6hyoOUviqJIBHDEF6zSsjI2IvE200lp3q4HOjCQt5trPng1Lqg5egnzGO5/aWvylRdG66PRatcRJVTAiPe59IrOyQiu6d4wDuQFB1Qi3oI9zDS5ddEQpFNRWyU85C75BruznhvV3KktfkE+nX1ONe6aRThLoXK3IIEIkq4vu8Or10HsUFoOTac8tnKSCwBD6RBvJ6jGJ9TiNDGv524za4QKV1jBDl/S5k45NjyFjXUC5Z94u7CIl88iduGLFE5kIKYjcDXoerNrmz3zoqIFJVwrcGd/bNGULkQRVXpGbLrv3J3+cBGk4LeWKC5WPvq1ao6GsVVw/cqyvOFh7vubfHXGx7rYz2cpkQT1PVHFdk5mY2mSzoeqWDwFNo0HRmuVzU2qoaXfPV3JoI4eUzIqWc8z1qchojlYUPI01hEn/nvuO3yx8F0niS+INxBp8AmzT5XrAA== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 69e36f8c-3436-4c6e-0a08-08da266e28eb X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:46:20.2346 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: Ffd2ylnok8VkHatqBzdN82Tz3IySR84LDwSj4fKridHAPkxJt3XapWuME/Sw6syMDM+fnQheGLlOPSVO5v3jsQ== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Add FW version fields to MDDQ device_info. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../ethernet/mellanox/mlxsw/core_linecards.c | 3 ++- drivers/net/ethernet/mellanox/mlxsw/reg.h | 27 ++++++++++++++++++- 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c index b5f5b31bd31e..42fe93ac629d 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c @@ -160,7 +160,8 @@ static int mlxsw_linecard_devices_attach(struct mlxsw_linecard *linecard) return err; mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq, &data_valid, &flash_owner, - &device_index); + &device_index, NULL, + NULL, NULL); if (!data_valid) break; err = mlxsw_linecard_device_attach(mlxsw_core, linecard, diff --git a/drivers/net/ethernet/mellanox/mlxsw/reg.h b/drivers/net/ethernet/mellanox/mlxsw/reg.h index 521c1b195a3e..04c4d7a4bd83 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/reg.h +++ b/drivers/net/ethernet/mellanox/mlxsw/reg.h @@ -11782,6 +11782,24 @@ MLXSW_ITEM32(reg, mddq, device_info_flash_owner, 0x10, 30, 1); */ MLXSW_ITEM32(reg, mddq, device_info_device_index, 0x10, 0, 8); +/* reg_mddq_device_info_fw_major + * Major FW version number. + * Access: RO + */ +MLXSW_ITEM32(reg, mddq, device_info_fw_major, 0x14, 16, 16); + +/* reg_mddq_device_info_fw_minor + * Minor FW version number. + * Access: RO + */ +MLXSW_ITEM32(reg, mddq, device_info_fw_minor, 0x18, 16, 16); + +/* reg_mddq_device_info_fw_sub_minor + * Sub-minor FW version number. + * Access: RO + */ +MLXSW_ITEM32(reg, mddq, device_info_fw_sub_minor, 0x18, 0, 16); + static inline void mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index, u8 request_msg_seq) @@ -11794,13 +11812,20 @@ mlxsw_reg_mddq_device_info_pack(char *payload, u8 slot_index, static inline void mlxsw_reg_mddq_device_info_unpack(const char *payload, u8 *p_response_msg_seq, bool *p_data_valid, bool *p_flash_owner, - u8 *p_device_index) + u8 *p_device_index, u16 *p_fw_major, + u16 *p_fw_minor, u16 *p_fw_sub_minor) { *p_response_msg_seq = mlxsw_reg_mddq_response_msg_seq_get(payload); *p_data_valid = mlxsw_reg_mddq_data_valid_get(payload); if (p_flash_owner) *p_flash_owner = mlxsw_reg_mddq_device_info_flash_owner_get(payload); *p_device_index = mlxsw_reg_mddq_device_info_device_index_get(payload); + if (p_fw_major) + *p_fw_major = mlxsw_reg_mddq_device_info_fw_major_get(payload); + if (p_fw_minor) + *p_fw_minor = mlxsw_reg_mddq_device_info_fw_minor_get(payload); + if (p_fw_sub_minor) + *p_fw_sub_minor = mlxsw_reg_mddq_device_info_fw_sub_minor_get(payload); } #define MLXSW_REG_MDDQ_SLOT_ASCII_NAME_LEN 20 From patchwork Mon Apr 25 03:44:30 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825247 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 4AF1CC433EF for ; Mon, 25 Apr 2022 03:47:35 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S239472AbiDYDue (ORCPT ); Sun, 24 Apr 2022 23:50:34 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:43248 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240678AbiDYDuH (ORCPT ); Sun, 24 Apr 2022 23:50:07 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2058.outbound.protection.outlook.com [40.107.220.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id B9F9E1EEFA for ; Sun, 24 Apr 2022 20:46:28 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=TSXTg7hOQchgGlvn7Zo+/Bjef8OftwyocC7QWvARo17psUg7OShFXGeTHM1O6V7qlaIsdrE9eO3n0lTIZ49CI9X/zzX5tg4aTb7SqY+clf5jyFspFF6uh3VPlVRUqqI/chc1GZD0uff74B4pzf8L7+gZt581H2WtVKiSA9jSFKIbIXuDjqz2tIsmzAnkYaGsQLB72pnaqVD5ShSnYwphwz3cauNPQcvR/whTCsIRmAVJel3Z/ypL6wG/kQ9N1K/sf1hvSwsmnNDrRc/ZU0JvDnqQ64AYW4w38Ais4EadxlQe1xgbAqgcKRof7HstG/HGdA5mMjLYytNXM/VhY2HAPg== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=PgpZqjs48kyiRR2izfok/sjVHTSzdMTHfx4KMAzZE8A=; b=NGT7q8eRzYsBtXvRYFyqOB6ZaZENpJpTYGkLfEzRj+h4PiYwu4EfkSD15nb/xKRvSl2TSCsDpexb5EqzyS+XWeRGVpCPhfJyOBdxVfQowtKnlbLwQEKgKpMJ1CydTYrLzuU0g0eiYlHiBLIgrWY9NzPjELPwW2V+zujtIDUebyd+US8kTKsb5XsbRUVyxVvpxPnbtbEZvhn1atBBxwyph3m2CrnHm0aMYs7j5IbhC6dSLbiX/BY5q5/qEwgVtWg2ohXCua70jeQhGnR3GHEub7PtNuZF2bhK0LsSm6gq7pdhuPQXDCF+7LQXKRK3T/kcwF7vIAOEebjzd/v1EOOt3Q== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=PgpZqjs48kyiRR2izfok/sjVHTSzdMTHfx4KMAzZE8A=; b=Zw2ZhcLCwHR+SdEacSLGqIYf8v4esCvlzD3aUsQNwEGl6nZNynHQLscBNB9bBkEfDt6f1ooa8332SXDszUXShr2Gjue+gep7TGXXJTqiDarwexEXcNU3lPoRUB7m2jFptiuMqxqPqCvl2TgSAfThDYbzOZSTcjeOKn+6eoY7vsitBNOG+02FYTcey8QZSVjmCE5/LqUiRRx4+Fef8JnD6auWNCqHJp1d8RjPGH9lKeWdBq9pvb/nGbqCAGjuIb5l6DGvetdHOBj7larL/dhyVy7365o9iOwHxwohc9tN7sewoVD7ZFJtTsCnQW2OzAOycU7ORZyiW0xHHf5+z75Rnw== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MW3PR12MB4521.namprd12.prod.outlook.com (2603:10b6:303:53::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Mon, 25 Apr 2022 03:46:26 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:46:26 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 10/11] mlxsw: core_linecards: Expose device FW version over device info Date: Mon, 25 Apr 2022 06:44:30 +0300 Message-Id: <20220425034431.3161260-11-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0202CA0006.eurprd02.prod.outlook.com (2603:10a6:803:14::19) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 8dcde429-01e5-44e8-4a02-08da266e2c94 X-MS-TrafficTypeDiagnostic: MW3PR12MB4521:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: 86fMN/I7Hz5ArT8M12QTpnGhbgcV/cQvKf4sEyZpp3lgQ+ZBXcm83CHnOkTt4rX9Kr8iOp8xe9s116x1s8kTuMJoIIs1j+nU62pYA64poT0j6EWPvjCQevl+wewn/6I5ETOCQYog0qvfPJvZ7geQlh10jGd5KxM/i/df5I08T/P74a9u0Aj1hiN9dpS/OPbhCqToYBOZSjamdZJYvkxgPgUZ+7rkX0L3CCp5kvvZkj9ExdZJYiORuagbt/ynDZKgFNpCR64TBvpyahnEBDDZInrH4XQVaUULJpp3jtPxm5iVI3xjUFKgJAx4B8D8/CcLz3yD6NGfb2UKfhzsMG9vk6zg2qikHJE1iLGoeT66ETdJDxjydScHQodG6Ov4OrRo4T3euRjJsXihdk2SpQz2wReA0sPinGr5eoUbY8kGr4obdm8Lt0bGpx1UCTdn7jIIMrL8ugheUNCNzQ/RLHZXRjEggwFH3oBJBL7a+Zi8gi3Iy5sMlILBInuwJgTHtz+kD85ABSzLaH9BAVb6FIX17ZRxzptdDcvH59+7ORObqMqZafR+HYiOCQnF18IQsB7u+Cn1nV603XxCwkuGZhvrHHZHaCM4lILV1o9BFBp40z6HuDmz4s3w7U8fFcHuPdH6xLDg2lAHJ2TAwiN5yDSSZw== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(4326008)(66556008)(6666004)(2616005)(66946007)(6512007)(5660300002)(107886003)(8936002)(86362001)(2906002)(1076003)(38100700002)(508600001)(6486002)(316002)(66476007)(8676002)(83380400001)(6916009)(186003)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: KWETZxjXv4z8hF+qnWYbIWa7zZyLPKTtESTAzKrK3/oGxf+Fw27Z2x8C/Ah5dAPpuxW4gavViRegRtw4hl9+8/2IHifxsIxSEJl+DU7v20HyzbpRHWLWw5Nb8vNZvwyu71/3/gxLd+7mqoxYcEJaKR3BVZ8Y4LdUjutlZ3Be+SOJIr8Lo8dMvIS7PRTufU+n1WZd5xNtHwdLbwUgv/Er3A2XWA7ALu7GxKuuoofbjOl/qV/GzcL1Pxmgrc4EyKwjEdV2wEdQfrjMCeavqVKukNfNm4Udl7qAGLoalo4Z2DHtz26Ru6ePVUaqoc+aNBK16BOdY1DEaV/kw6sJt1Z5jASmyuJqTTaJAg7XmVU71TDKWiVT+rRSGAe0ApqVWh8SFhVzFZoF5UdaoUZKEiftedZfuOBbkkg99PPvt5rKYCVpaBnKjGl2LWMJ0Jkp1XII7Pqk5Q3w8uf1mZ5dq+uUrepzDdFZ+0dPIXEkeA6nTxDENY3+eX04EeNMvQqt6JsvhVwqDWsxlI0NH8SJ+qd3zRU/DvlfUKwSIMKh2B+HAJ3zt5Kym2gu59yg3DtfDqEdOwT9XepvJLG6GIExBFzU0cfO7QjNOvYMfwp3bAICHJicxmWJLG/389Riw6pmsbsfYAQEy7KE0n/ly316JNRVzxIkMStGFHzybx8FuE5YXseeSSS1T1evw1zqfnFJoQRXv54t+KwQV5gwtXwN2hPLGO9An/n/zZk0F5r6QUtisScrOZLeZNt1vAiPb7nX+4Zgxsl1pk2dgnzVZ+GgLjEAvQbJqAGblg7cmLt/RsNevzCtyEjoB54bWkH39NU7PwTnLJQTJQ/l3Fm5qUzXowyWNQUe+OkP3TNEZv1S47Z+L5qN+aDUYor8xv8u2rW3gGlYnmSgLY53/nTFN4MzKqtzirosoN4dH4umCJkv0Zsg4aYTSL136KhUKxBPz2k8AP95wEm3+EIa+yhozRNlzs6AGK1BOZUf+/nouCus5+zn/eXagN7bZio4f0193DgqVl6b8yCu2mcTE6aj/PwohgUodA2x6L1rtoPZUBROgW0Nh89IWkJzYARNpPYuAc69IeDqU2NqYBIkyEDMOFtspN5U+skaBYOzZFvpzITAbtvRRyzSAmXw8JWJj1xrF6fvCrHETU7XKZ04BW0JmOZQqIBqRz5dLmDpAozPKY/DIOc+TosX27r9RUWAnfo0WU/gGEpThMMRQdjmS3NlYCyVKQsuuvXjxRuQnZOhXmodPYWacG4ePtx6LiaVFhhwtxmTLAqeKzR/UiOzMIHmaAUuKwupTkOW9RRp8WlVtkFsFSv33wOwVO4k8n4AhMFdxQjhZMMR+E2kr7KAd+BNyjZ93LiAuQ4ZjoZ4xLqRnwoZgRCdoOMrA9UufebHcVNcY/tmmky+6TcWIG+wy1uP1CX3eE4Bi3GYuJw/mN1Vds+o7oKscqYXQpFQhpmerUH2CSdcekF4zN1F8hJdOhh8PfpvuIGL2S0zqrbcZzZ49V7CM9HbuvvKN03mYzh8LFvp6sbd0ugaXH97BqOX2hiTQ/WyWy5SUkfMWAaUNwDnd+/8X6H0XpnpnVD3W2J/uIkXifjTaJakAIlwoknI/lYVwGEsJeEsIlQQU4O+Utl+gp9OMcfc5F/4kXniez/LqySO91YP6RXZ2VYC8hgbuj5WU34vtb2vx8E7k/odChIuzrWu5vfl7I9z4VKXpSRpoXUU3mSAc6HPkMSB41XYPEN+vQ8atggzMg== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 8dcde429-01e5-44e8-4a02-08da266e2c94 X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:46:26.3613 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: 5rLKTlsmilwjyxl0wCRgSHrAKUja7B9adf1FEdfvIxvm5wBmdeB+Jn0j3Hm95/Sf4rHlWUaN+ayakXN69LtG7g== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Extend MDDQ to obtain FW version of line card device and implement device_info_get() op to fill up the info with that. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- Documentation/networking/devlink/mlxsw.rst | 15 +++ .../ethernet/mellanox/mlxsw/core_linecards.c | 108 +++++++++++++++++- 2 files changed, 119 insertions(+), 4 deletions(-) diff --git a/Documentation/networking/devlink/mlxsw.rst b/Documentation/networking/devlink/mlxsw.rst index da1fbb265a11..0af345680510 100644 --- a/Documentation/networking/devlink/mlxsw.rst +++ b/Documentation/networking/devlink/mlxsw.rst @@ -76,6 +76,21 @@ The ``mlxsw`` driver reports the following versions for line cards - running - Version of line card INI loaded +Line card device info versions +============================== + +The ``mlxsw`` driver reports the following versions for line card devices + +.. list-table:: devlink line card device info versions implemented + :widths: 5 5 90 + + * - Name + - Type + - Description + * - ``fw.version`` + - running + - Three digit firmware version + Driver-specific Traps ===================== diff --git a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c index 42fe93ac629d..2abd31a62776 100644 --- a/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c +++ b/drivers/net/ethernet/mellanox/mlxsw/core_linecards.c @@ -87,13 +87,31 @@ static const char *mlxsw_linecard_type_name(struct mlxsw_linecard *linecard) return linecard->name; } +struct mlxsw_linecard_device_info { + u16 fw_major; + u16 fw_minor; + u16 fw_sub_minor; +}; + struct mlxsw_linecard_device { struct list_head list; u8 index; struct mlxsw_linecard *linecard; struct devlink_linecard_device *devlink_device; + struct mlxsw_linecard_device_info info; }; +static struct mlxsw_linecard_device * +mlxsw_linecard_device_lookup(struct mlxsw_linecard *linecard, u8 index) +{ + struct mlxsw_linecard_device *device; + + list_for_each_entry(device, &linecard->device_list, list) + if (device->index == index) + return device; + return NULL; +} + static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, struct mlxsw_linecard *linecard, u8 device_index, bool flash_owner) @@ -108,7 +126,7 @@ static int mlxsw_linecard_device_attach(struct mlxsw_core *mlxsw_core, device->linecard = linecard; device->devlink_device = devlink_linecard_device_create(linecard->devlink_linecard, - device_index, NULL); + device_index, device); if (IS_ERR(device->devlink_device)) { err = PTR_ERR(device->devlink_device); goto err_devlink_linecard_device_attach; @@ -177,6 +195,77 @@ static int mlxsw_linecard_devices_attach(struct mlxsw_linecard *linecard) return err; } +static void mlxsw_linecard_device_update(struct mlxsw_linecard *linecard, + u8 device_index, + struct mlxsw_linecard_device_info *info) +{ + struct mlxsw_linecard_device *device; + + device = mlxsw_linecard_device_lookup(linecard, device_index); + if (!device) + return; + device->info = *info; +} + +static int mlxsw_linecard_devices_update(struct mlxsw_linecard *linecard) +{ + struct mlxsw_core *mlxsw_core = linecard->linecards->mlxsw_core; + u8 msg_seq = 0; + + do { + struct mlxsw_linecard_device_info info; + char mddq_pl[MLXSW_REG_MDDQ_LEN]; + bool data_valid; + u8 device_index; + int err; + + mlxsw_reg_mddq_device_info_pack(mddq_pl, linecard->slot_index, + msg_seq); + err = mlxsw_reg_query(mlxsw_core, MLXSW_REG(mddq), mddq_pl); + if (err) + return err; + mlxsw_reg_mddq_device_info_unpack(mddq_pl, &msg_seq, + &data_valid, NULL, + &device_index, + &info.fw_major, + &info.fw_minor, + &info.fw_sub_minor); + if (!data_valid) + break; + mlxsw_linecard_device_update(linecard, device_index, &info); + } while (msg_seq); + + return 0; +} + +static int +mlxsw_linecard_device_info_get(struct devlink_linecard_device *devlink_linecard_device, + void *priv, struct devlink_info_req *req, + struct netlink_ext_ack *extack) +{ + struct mlxsw_linecard_device *device = priv; + struct mlxsw_linecard_device_info *info; + struct mlxsw_linecard *linecard; + char buf[32]; + + linecard = device->linecard; + mutex_lock(&linecard->lock); + if (!linecard->active) { + mutex_unlock(&linecard->lock); + return 0; + } + + info = &device->info; + + sprintf(buf, "%u.%u.%u", info->fw_major, info->fw_minor, + info->fw_sub_minor); + mutex_unlock(&linecard->lock); + + return devlink_info_version_running_put(req, + DEVLINK_INFO_VERSION_GENERIC_FW, + buf); +} + static void mlxsw_linecard_provision_fail(struct mlxsw_linecard *linecard) { linecard->provisioned = false; @@ -390,11 +479,18 @@ static int mlxsw_linecard_ready_clear(struct mlxsw_linecard *linecard) return 0; } -static void mlxsw_linecard_active_set(struct mlxsw_linecard *linecard) +static int mlxsw_linecard_active_set(struct mlxsw_linecard *linecard) { + int err; + + err = mlxsw_linecard_devices_update(linecard); + if (err) + return err; + mlxsw_linecard_active_ops_call(linecard); linecard->active = true; devlink_linecard_activate(linecard->devlink_linecard); + return 0; } static void mlxsw_linecard_active_clear(struct mlxsw_linecard *linecard) @@ -443,8 +539,11 @@ static int mlxsw_linecard_status_process(struct mlxsw_linecards *linecards, goto out; } - if (active && linecard->active != active) - mlxsw_linecard_active_set(linecard); + if (active && linecard->active != active) { + err = mlxsw_linecard_active_set(linecard); + if (err) + goto out; + } if (!active && linecard->active != active) mlxsw_linecard_active_clear(linecard); @@ -872,6 +971,7 @@ static const struct devlink_linecard_ops mlxsw_linecard_ops = { .types_count = mlxsw_linecard_types_count, .types_get = mlxsw_linecard_types_get, .info_get = mlxsw_linecard_info_get, + .device_info_get = mlxsw_linecard_device_info_get, }; struct mlxsw_linecard_status_event { From patchwork Mon Apr 25 03:44:31 2022 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Ido Schimmel X-Patchwork-Id: 12825248 X-Patchwork-Delegate: kuba@kernel.org Return-Path: X-Spam-Checker-Version: SpamAssassin 3.4.0 (2014-02-07) on aws-us-west-2-korg-lkml-1.web.codeaurora.org Received: from vger.kernel.org (vger.kernel.org [23.128.96.18]) by smtp.lore.kernel.org (Postfix) with ESMTP id 3722EC433FE for ; Mon, 25 Apr 2022 03:47:41 +0000 (UTC) Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S236822AbiDYDug (ORCPT ); Sun, 24 Apr 2022 23:50:36 -0400 Received: from lindbergh.monkeyblade.net ([23.128.96.19]:45518 "EHLO lindbergh.monkeyblade.net" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S240854AbiDYDuI (ORCPT ); Sun, 24 Apr 2022 23:50:08 -0400 Received: from NAM11-CO1-obe.outbound.protection.outlook.com (mail-co1nam11on2058.outbound.protection.outlook.com [40.107.220.58]) by lindbergh.monkeyblade.net (Postfix) with ESMTPS id F21BC22B01 for ; Sun, 24 Apr 2022 20:46:33 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; s=arcselector9901; d=microsoft.com; cv=none; b=SdWyEnhIhtSapYpxR/nqfqsBLmjPbQ8TUMMN1zW79wuIdDBNhRuPTiq7qbNwmW5WRvXSSR6MDQbjomDPGUnuVmxULUeUpEWnrp4LjpBwf5uXfcn6PqhrskCRKa3XYOVldm5J51YKmTTwqBpEYmH09lEefDK6I5KRtdE/8q0ix1UXGvR4TVrHEelN3ibpRy1jkl9LB8ZbZAwTbzYFOQ7Jp3gYjYckr8sLTz9LxE2rGkRU+kVfiIHILPzKRPxSSI0lhDanNZrPpvGC5NuF0A07du9IWC0kBKFVtydpvegHATMcw6IFu/0Po9ZDJxdzF983ppjk7owG3ORzT5fqrb5rng== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=microsoft.com; s=arcselector9901; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-AntiSpam-MessageData-ChunkCount:X-MS-Exchange-AntiSpam-MessageData-0:X-MS-Exchange-AntiSpam-MessageData-1; bh=/ghHFcWHHWvyGhQSGiz6lu42o527oTVK69uf/sVE7J4=; b=lWCEmLBID1U8hSAFPi5V0XesUKdYnNsK7bJ5BtmnMoD/Ysh/w3WsR82wA4p1FxGe5uCZqKz12q410DeyVuMluCSLbe7eP8o5a+ea1RLtMRZYKzWR4k0QvZhsnHg8JZp4mUztzrkiTPov6aVgAUmwf0yg9W/hMHJFyRq6bF5XjHn64hLJre6ORRGRk3/NflTLVVp+ZbQfNje59T0MPSG5ymSvg8BeR1vHz50QEM1bwLL7lD0ol8Y/2iGB/DXx6iazTlYtKFSOKcmLU0OUANrr8f5KJ5luN+K19OfmP9ZY64IRFCKaL/5kaHZaMVx4IgPKy9yRd7OAMzb5n/zhemWRHw== ARC-Authentication-Results: i=1; mx.microsoft.com 1; spf=pass smtp.mailfrom=nvidia.com; dmarc=pass action=none header.from=nvidia.com; dkim=pass header.d=nvidia.com; arc=none DKIM-Signature: v=1; a=rsa-sha256; c=relaxed/relaxed; d=Nvidia.com; s=selector2; h=From:Date:Subject:Message-ID:Content-Type:MIME-Version:X-MS-Exchange-SenderADCheck; bh=/ghHFcWHHWvyGhQSGiz6lu42o527oTVK69uf/sVE7J4=; b=QXlJFIaf4ap4ZG7QgIEe2gI7haXben82BjajOpUq0VrdqH3THBoBlxU/2JYehv4dy+xTNGPcXGNTJIOGOlmZHZioVYNSi56rzJfx91nOW2nH0MfMfXADpK5r53rE+kbb4hbAR+i3diXUvRuHzIe14OTE/8HIdXAqAZKUQlzHjkmU7skLqImYLjiWYu8E5qrsImXZjazCKQY0Djv5QZ2fsU3l/uN/0YHvxwrbua3dA1fNJB3/g1rPIHpMBfllE+2f3FfUff3hskIWfGgLKhOR8rocZXMtzo72A9fSCiP0IoKLyME219SZBehKoVaxqOwxge5saUimmnymvsz50pVuoA== Authentication-Results: dkim=none (message not signed) header.d=none;dmarc=none action=none header.from=nvidia.com; Received: from DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) by MW3PR12MB4521.namprd12.prod.outlook.com (2603:10b6:303:53::13) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_256_GCM_SHA384) id 15.20.5186.15; Mon, 25 Apr 2022 03:46:32 +0000 Received: from DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331]) by DM6PR12MB4337.namprd12.prod.outlook.com ([fe80::45b7:af36:457d:7331%6]) with mapi id 15.20.5186.021; Mon, 25 Apr 2022 03:46:32 +0000 From: Ido Schimmel To: netdev@vger.kernel.org Cc: davem@davemloft.net, kuba@kernel.org, pabeni@redhat.com, jiri@nvidia.com, petrm@nvidia.com, dsahern@gmail.com, andrew@lunn.ch, mlxsw@nvidia.com, Ido Schimmel Subject: [PATCH net-next 11/11] selftests: mlxsw: Check device info on activated line card Date: Mon, 25 Apr 2022 06:44:31 +0300 Message-Id: <20220425034431.3161260-12-idosch@nvidia.com> X-Mailer: git-send-email 2.33.1 In-Reply-To: <20220425034431.3161260-1-idosch@nvidia.com> References: <20220425034431.3161260-1-idosch@nvidia.com> X-ClientProxiedBy: VI1PR0202CA0003.eurprd02.prod.outlook.com (2603:10a6:803:14::16) To DM6PR12MB4337.namprd12.prod.outlook.com (2603:10b6:5:2a9::12) MIME-Version: 1.0 X-MS-PublicTrafficType: Email X-MS-Office365-Filtering-Correlation-Id: 63553e68-c218-4f52-b507-08da266e303d X-MS-TrafficTypeDiagnostic: MW3PR12MB4521:EE_ X-Microsoft-Antispam-PRVS: X-MS-Exchange-SenderADCheck: 1 X-MS-Exchange-AntiSpam-Relay: 0 X-Microsoft-Antispam: BCL:0; X-Microsoft-Antispam-Message-Info: bDDX5ecAooz9qK/9zRXkA+HaA8v9zsbPXBuIDHOdSS/H78hRQikom+IMXbSheiqJAhRuc6WnlQFY9IbRF+UEfVml+xODf1V/+/Jd3wf2431aeFDZjkAa4fOk4M10TDmkAG8qTf0pYcDeyqnkZn1QnikmndG9cdV4k1V5FY2axb9Avu4q4mTmiuhV5KL9KDSgUx0vaR2SV2oOLEBSCtqvZNVPMRH5rjjEyBgUybA2Q0Eb38yJLF3knLcS74akEJ6qETacdRB6gjkxFKaVXLgisxlLmY+0cBLFhwtpyrXbI+hu+gIEo2wNellcNqPLVFDrfsSQsbw+CHHGGbxspzdR+tLmTAjd4BucyUkO16GiSF4UtW6uAax+ppifbQjAAwQoQrdMoPLYtpvmTpmbmtM6sIS/Icn7jGS1nzEFhRwqna4jkrb1Nyk7KnakooB8hMubfxaCutUohmHJBnCsc4qJMZeWqouQIU5dE75bEtJ4O/xbckJ08EiAEI9POBJQrcl9fnPCH0tdY87cbdEpwK0UFMuZIKpqL+ZNQmmC7AjiInwZpsrW/GmZkWOP55YtHUUksAq1mMLWDq2dnXY8IYZm+pEkVBItfKbPWPfIYNW5EgVlppoM/KVYwu1+IRUFZdtChCGoS2sQBLwNrqMHGresmQ== X-Forefront-Antispam-Report: CIP:255.255.255.255;CTRY:;LANG:en;SCL:1;SRV:;IPV:NLI;SFV:NSPM;H:DM6PR12MB4337.namprd12.prod.outlook.com;PTR:;CAT:NONE;SFS:(13230001)(4636009)(366004)(26005)(4326008)(66556008)(2616005)(66946007)(6512007)(5660300002)(107886003)(8936002)(86362001)(2906002)(1076003)(38100700002)(508600001)(6486002)(316002)(66476007)(8676002)(83380400001)(6916009)(186003)(6506007)(36756003);DIR:OUT;SFP:1101; X-MS-Exchange-AntiSpam-MessageData-ChunkCount: 1 X-MS-Exchange-AntiSpam-MessageData-0: EVD/4KUixEhQe4n5sg8QCyhlYXaRzhYacXLrssWaBYoaXyHnLGLPQrzxRetY3l9wdTsyqjBB0sqKFwBjERNTDQtfK1c83eaVVIYkV49Ve4QDzgasjr28PvJKAINwwTLzYYhDoDT3/opVrlRdtJmehoXKW7iRlrX6thAuvTo2kkiEmUFnlZFOqgNilTKWb1erw5ONTJQw05pia0PIEW0XbE+KFoOHoXOCuY3WVGg3sGQDkyTBiFl9dxYPBlnPpEtJCbcSVKrkV9xz8UxwMG/y1VvPrpFAlMNn53BtpqNAd5AMkW5LzlT3eW5+3OvaBOtDMh8afcRmsEFe2S8NImQJdh2VMVLU7yvXCZ8/CWznmpBUL0Fc2+J8NTNOTytgR/q5stA+yBmN7aAACSYdrExLOIDbDxPeN8BBNbF4nZP+AV7y+mfTeX8AOqp44tOOtnGbw12maecoDDeZTJR2u5bhnaF/fPWOtvFWru65sTgmG7LEU2YNF425Lvx2uSGAjEvcmYI/6ZnhVEG+gJLp9/wjiZcCVLKcrkofRZTAqy6wIQ9JJVxL+H8QITa9G5t1InP7nXcQvVM2Ql9cww3nhgBP0w7uRHkHKCu4mCWmS5SZ0erye+P+YOAmcL3G/sVbTlAM3hEb9sxNxxik7pUroWCZFgMs/i9MyWpGliklOfbcgd63eR9S8TeAExWqppSodli7y91JWY7Sen6BqY10zdEmi5rgdVfPZ2ku1zlUtW21OstUAyTkL0FasRqlSwbnpj2z46VNiFGo54629frxQHe0woxK3ud8GTQzRrCRpKTwttky8L9Zxn8VfydqvLnV8ovxhBrbWjcL3CTNWW4RVQYKy3+bmqyc4c7n+pHde0HEP3cOFFbX7T7epPRc81O7eMFFBb2QDT/DP/gshCjkL3vNLWO/MS7isvnASal5a37UbdgeVSDjMoA53CmVh14/3efUFto4IG1upKEgf0PYdUPg0NxeSnhcaE426/gc4I69yq8eFxQrDX+hJdcGH0zytl4ntP5ymyzslsXWBgrmNbwzJugG7px+8kA7JmTeRL4v8a1TNnHSlu+jYK9e9r9P5vIvJcb/R9AtrgxBXyrOPRJtMWuRbMnHNirqecdlNaw9NJJZa0Dde9y3idgphYXM6SNt3yx5GAHhC9lNejfCXdjdk2NDzDlwE9Kl2VxNGV2BwLQwswlqXyLDRnHFUSVne0YYl2mwSLNLiO/KoRnsN7AIjri2x6l7Lhp2C9YRhHBHDJT9crnBv3IfPKE2EtPYDMnJ01lvvyQ/Ngh/ZM3pum94ofRRRe3nxEE7nMQD9q2sK/PiKgw8+o6OSZsJjb9Fy2WIl4b/mRch81W+QyGkDOerPh59nJvVXZJiiWaEmBUzO8w4GprOTHasPvMpuydlGwgvxicOSLe97RNg6cMV24YLyuTWfQz5ZB96SXb1ANm1Vz+Lhw3duLfQ5B4TL3sZiNY8oW+gKEOkxzoBcCuGR51JvbYwuLIPgIpVN2c85k7qFJ2VvXKM2ALE5tDK8QV/34Lf/EQK736utAwtcLrepAuxvRnnrqss28PP8++YOJ+E/PKiDvHXhb8YaWZeLAp3Ll+5faBV90H4Ozv58iEQzRkbg0UdPxkhK0ygWZ6TVQE4mC6eiJ8jGikHauf6wuzWYQaIfRSJ1T0+EU7YmxWo+ng/uBqHpiiGQVQBxMPCyOdmkRN4A7MU5BFt0JxJbPrzAcUkoTgftTEtkF/B32qBn2SHOQ== X-OriginatorOrg: Nvidia.com X-MS-Exchange-CrossTenant-Network-Message-Id: 63553e68-c218-4f52-b507-08da266e303d X-MS-Exchange-CrossTenant-AuthSource: DM6PR12MB4337.namprd12.prod.outlook.com X-MS-Exchange-CrossTenant-AuthAs: Internal X-MS-Exchange-CrossTenant-OriginalArrivalTime: 25 Apr 2022 03:46:32.5047 (UTC) X-MS-Exchange-CrossTenant-FromEntityHeader: Hosted X-MS-Exchange-CrossTenant-Id: 43083d15-7273-40c1-b7db-39efd9ccc17a X-MS-Exchange-CrossTenant-MailboxType: HOSTED X-MS-Exchange-CrossTenant-UserPrincipalName: AVNZ8pEOcOg5x9KglKfDpLr6HykRQjXbfFOTb6JD2vBg1nGwkA1DR5v1Ze2GYyzJC9RskENjIWv2i7qCmskTDA== X-MS-Exchange-Transport-CrossTenantHeadersStamped: MW3PR12MB4521 Precedence: bulk List-ID: X-Mailing-List: netdev@vger.kernel.org X-Patchwork-Delegate: kuba@kernel.org From: Jiri Pirko Once line card is activated, check the device FW version is exposed. Signed-off-by: Jiri Pirko Signed-off-by: Ido Schimmel --- .../drivers/net/mlxsw/devlink_linecard.sh | 22 +++++++++++++++++++ 1 file changed, 22 insertions(+) diff --git a/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh b/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh index 04bedd98eb8b..53a65f416770 100755 --- a/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh +++ b/tools/testing/selftests/drivers/net/mlxsw/devlink_linecard.sh @@ -259,6 +259,26 @@ interface_check() setup_wait } +lc_devices_info_check() +{ + local lc=$1 + local expected_device_count=$2 + local device_count + local device + local running_device_fw + + device_count=$(devlink lc info $DEVLINK_DEV lc $lc -j | \ + jq -e -r ".[][][].devices |length") + check_err $? "Failed to get linecard $lc device count" + for (( device=0; device