Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp3728457ybz; Mon, 20 Apr 2020 08:23:01 -0700 (PDT) X-Google-Smtp-Source: APiQypLTDA9uHZVKNj2aEAUjjdphuQEFU3PkyAS27DrTyI/OwQGmsH+ES43yLjo72y64u6rsXJXI X-Received: by 2002:aa7:d7d8:: with SMTP id e24mr14923058eds.215.1587396181139; Mon, 20 Apr 2020 08:23:01 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587396181; cv=none; d=google.com; s=arc-20160816; b=vTOl7OyXChrzbH6A31z+dg4UQmyoWPvHWCAOhYgEKGerrDtEpDxUnink71E3CQ1v69 JvYIUoJVVYTNrc3t+hTKq3W+/H4MLxPmOLQ5iRe2lSC6/Sh6s9VD3DtxRI+6q7epkXAT Qwe1AndmFNjrJ7qsZpjHXC9eaCOEl/ewwf2LTQjgno6E5iW2X4PY8nxZ7pCxinU8xMeP Km4sW6pGMEHiyfgZFgWIbhKMRKtkre3d+rBjgxCcEvKfunSE7MuFTTsK6ZbVYy95FDP4 gFy9uygcTkf1eP8ed9uZs223KQmyKwsXeDqgs+BxzRmd3JYBx7HMHFUVjhuPghtuAwhs +jEw== ARC-Message-Signature: i=1; a=rsa-sha256; c=relaxed/relaxed; d=google.com; s=arc-20160816; h=list-id:precedence:sender:mime-version:references:in-reply-to :message-id:date:subject:cc:to:from:ironport-sdr:dkim-signature; bh=YszCmbzWy2DsMAkX5CQjuDQkO/2Ls0nOQzAjPW9r+4A=; b=SuUIcY74jQSELnAXVNce5Zgv5QNl6NzalXVAfRsKFwOq+94SDge3nuqrvrHqVLQcRf yC56Q1S70UrHBNM0lsDkOcowGF9JUBs57i3ei0FOdlRVc3dDX64ACi8DDrRsj0FOSPIP AqvTVdqVxk03b1JkX2tCzHLcQq1KG+hZzO0639wouirkG5IBrG/9M9X/Y8IT6JVeYXCX bFkRrFmtfiL0dvHJrEXqPBcp4VIbBCMyDUv8j5fS98+91jetQece1HHs+eDvZrK0fpQh JRXjsRsZisXXpvposCtOclRlPN5rV08D7+wotVlkx7pcXHYboEeZHboWrLq3CfKxy0Ir IgMA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=uaBDmj8T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Return-Path: Received: from vger.kernel.org (vger.kernel.org. [23.128.96.18]) by mx.google.com with ESMTP id 23si705680ejn.282.2020.04.20.08.22.36; Mon, 20 Apr 2020 08:23:01 -0700 (PDT) Received-SPF: pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) client-ip=23.128.96.18; Authentication-Results: mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b=uaBDmj8T; spf=pass (google.com: domain of linux-kernel-owner@vger.kernel.org designates 23.128.96.18 as permitted sender) smtp.mailfrom=linux-kernel-owner@vger.kernel.org; dmarc=fail (p=NONE sp=NONE dis=NONE) header.from=microchip.com Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1730186AbgDTPMy (ORCPT + 99 others); Mon, 20 Apr 2020 11:12:54 -0400 Received: from esa2.microchip.iphmx.com ([68.232.149.84]:38961 "EHLO esa2.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1730189AbgDTPMD (ORCPT ); Mon, 20 Apr 2020 11:12:03 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1587395522; x=1618931522; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=Wk5W6JOrVyShu0Bu566DjA/nJMtV0L8hDnh56QYpSOM=; b=uaBDmj8TWjB5B6tF6X9EUH7zLr/q9cUp5ITouwbRtvCUakbE+InjzeH0 R+hCU0JQmtoAXH6nSGl+qYuPVCew1FFzRpqJNb8HESSPwDsXUTc0eyjxE DySQskfxs2iRsGFbKDu4RM9FTsH/tqrcijuShqZyXO2KabUXI9Z207ShU X1k0ibwBGv6MESsmvGNJmonm/ZAko13g1OCiJ8Af2IjDQZOQm2XVwyqlS WO2/MhM+fykjp0w3A9NQ8U++XMN4JdfJQO/Ic3W8B6Z0sbIEtzKNlT3mT Gg2sWpC06xKgNNeUnIE6c4lK4OH/kwqM6n8E3RHacT4TCN+Zz/AFEInq/ Q==; IronPort-SDR: iDuceTZ3lhtWv0/inC4A/4Av3OD0q1/GaXu6hx49hOcWgWkps6ZYHeuZjT5iVxDUQ94yon5qHR ww5O4pAs8511kaZfGD8GvfnAMNDP3U27OosCIC+hKu1Jg/m000BSAH9H1tjs6/pumCZfPs3C/R CLt0b4TIQoXk6+M6iPpqqT4IUzdugS5k8SgvOZwmtBuiwZolFlynLDnKv/sChuQJ3pZ6oZSUB9 0oOUD17JX5XwsIJyBCYzVzeF6kcMkwyVZS9oEBYawM7EhhcSJZ4t1UIZ/zDvSjFOEaoFHNdvWL +cQ= X-IronPort-AV: E=Sophos;i="5.72,406,1580799600"; d="scan'208";a="72755110" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa2.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 20 Apr 2020 08:12:02 -0700 Received: from chn-vm-ex02.mchp-main.com (10.10.85.144) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Mon, 20 Apr 2020 08:12:02 -0700 Received: from soft-dev3.microsemi.net (10.10.115.15) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Mon, 20 Apr 2020 08:11:31 -0700 From: Horatiu Vultur To: , , , , , , , , , , , CC: Horatiu Vultur Subject: [PATCH net-next 07/13] switchdev: mrp: Extend switchdev API to offload MRP Date: Mon, 20 Apr 2020 17:09:41 +0200 Message-ID: <20200420150947.30974-8-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200420150947.30974-1-horatiu.vultur@microchip.com> References: <20200420150947.30974-1-horatiu.vultur@microchip.com> MIME-Version: 1.0 Content-Type: text/plain Sender: linux-kernel-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-kernel@vger.kernel.org Extend switchdev API to add support for MRP. The HW is notified in following cases: SWITCHDEV_OBJ_ID_MRP: This is used when a MRP instance is added/removed from the MRP ring. SWITCHDEV_OBJ_ID_RING_ROLE_MRP: This is used when the role of the node changes. The current supported roles are MRM and MRC. SWITCHDEV_OBJ_ID_RING_TEST_MRP: This is used when to start/stop sending MRP_Test frames on the mrp ring ports. This is called only on nodes that have the role MRM. In case this fails then the SW will generate the frames. SWITCHDEV_OBJ_ID_RING_STATE_STATE: This is used when the ring changes it states to open or closed. This is required to notify HW because the MRP_Test frame contains the field MRP_InState which contains this information. SWITCHDEV_ATTR_ID_MRP_PORT_STATE: This is used when the port's state is changed. It can be in blocking/forwarding mode. SWITCHDEV_ATTR_ID_MRP_PORT_ROLE: This is used when port's role changes. The roles of the port can be primary/secondary. This is required to notify HW because the MRP_Test frame contains the field MRP_PortRole that contains this information. Signed-off-by: Horatiu Vultur --- include/net/switchdev.h | 62 +++++++++++++++++++++++++++++++++++++++++ 1 file changed, 62 insertions(+) diff --git a/include/net/switchdev.h b/include/net/switchdev.h index aee86a189432..ae7aeb0d1f9c 100644 --- a/include/net/switchdev.h +++ b/include/net/switchdev.h @@ -40,6 +40,10 @@ enum switchdev_attr_id { SWITCHDEV_ATTR_ID_BRIDGE_VLAN_FILTERING, SWITCHDEV_ATTR_ID_BRIDGE_MC_DISABLED, SWITCHDEV_ATTR_ID_BRIDGE_MROUTER, +#if IS_ENABLED(CONFIG_BRIDGE_MRP) + SWITCHDEV_ATTR_ID_MRP_PORT_STATE, + SWITCHDEV_ATTR_ID_MRP_PORT_ROLE, +#endif }; struct switchdev_attr { @@ -55,6 +59,11 @@ struct switchdev_attr { clock_t ageing_time; /* BRIDGE_AGEING_TIME */ bool vlan_filtering; /* BRIDGE_VLAN_FILTERING */ bool mc_disabled; /* MC_DISABLED */ +#if IS_ENABLED(CONFIG_BRIDGE_MRP) + u8 mrp_port_state; /* MRP_PORT_STATE */ + u8 mrp_port_role; /* MRP_PORT_ROLE */ + u8 mrp_ring_state; /* MRP_RING_STATE */ +#endif } u; }; @@ -63,6 +72,12 @@ enum switchdev_obj_id { SWITCHDEV_OBJ_ID_PORT_VLAN, SWITCHDEV_OBJ_ID_PORT_MDB, SWITCHDEV_OBJ_ID_HOST_MDB, +#if IS_ENABLED(CONFIG_BRIDGE_MRP) + SWITCHDEV_OBJ_ID_MRP, + SWITCHDEV_OBJ_ID_RING_TEST_MRP, + SWITCHDEV_OBJ_ID_RING_ROLE_MRP, + SWITCHDEV_OBJ_ID_RING_STATE_MRP, +#endif }; struct switchdev_obj { @@ -94,6 +109,53 @@ struct switchdev_obj_port_mdb { #define SWITCHDEV_OBJ_PORT_MDB(OBJ) \ container_of((OBJ), struct switchdev_obj_port_mdb, obj) + +#if IS_ENABLED(CONFIG_BRIDGE_MRP) +/* SWITCHDEV_OBJ_ID_MRP */ +struct switchdev_obj_mrp { + struct switchdev_obj obj; + struct net_device *p_port; + struct net_device *s_port; + u32 ring_id; +}; + +#define SWITCHDEV_OBJ_MRP(OBJ) \ + container_of((OBJ), struct switchdev_obj_mrp, obj) + +/* SWITCHDEV_OBJ_ID_RING_TEST_MRP */ +struct switchdev_obj_ring_test_mrp { + struct switchdev_obj obj; + /* The value is in us and a value of 0 represents to stop */ + u32 interval; + u8 max_miss; + u32 ring_id; + u32 period; +}; + +#define SWITCHDEV_OBJ_RING_TEST_MRP(OBJ) \ + container_of((OBJ), struct switchdev_obj_ring_test_mrp, obj) + +/* SWICHDEV_OBJ_ID_RING_ROLE_MRP */ +struct switchdev_obj_ring_role_mrp { + struct switchdev_obj obj; + u8 ring_role; + u32 ring_id; +}; + +#define SWITCHDEV_OBJ_RING_ROLE_MRP(OBJ) \ + container_of((OBJ), struct switchdev_obj_ring_role_mrp, obj) + +struct switchdev_obj_ring_state_mrp { + struct switchdev_obj obj; + u8 ring_state; + u32 ring_id; +}; + +#define SWITCHDEV_OBJ_RING_STATE_MRP(OBJ) \ + container_of((OBJ), struct switchdev_obj_ring_state_mrp, obj) + +#endif + typedef int switchdev_obj_dump_cb_t(struct switchdev_obj *obj); enum switchdev_notifier_type { -- 2.17.1