Received: by 2002:a25:1985:0:0:0:0:0 with SMTP id 127csp215982ybz; Tue, 21 Apr 2020 07:45:43 -0700 (PDT) X-Google-Smtp-Source: APiQypLACpdWXGvEy+HYkj0blRZcEcfed2zkPr5OgoRopSirVvRi730g82UUOkyohWt9q2f6KrWz X-Received: by 2002:a50:ed8f:: with SMTP id h15mr19671770edr.331.1587480342856; Tue, 21 Apr 2020 07:45:42 -0700 (PDT) ARC-Seal: i=1; a=rsa-sha256; t=1587480342; cv=none; d=google.com; s=arc-20160816; b=tT6BbCUedY5q02JRQVMXb/Eu7mbLf+OVaK9BYj1aBXaWp2vdpezCG04vublBQo8EYD K0dXhX8+PybPb8awHXcX0uQI/FJhd0kAZ3FQ4llVxAE2zM5DOR04oYfG4UPUe6ANpStb 11JsAlNdCDxLZe9/t2jFdTGoSqqaPmyCbbc99re0GApefQprGeAHpP8bvpkmjIlhdCtz W4CKH/O33lbd9/syaBRL5aRe8YKIJYGwRKrLeirxwH9YvqZVNM2LyWMf4jGr5nG3yLTj UytluNp7ODXRwZAliAxgsi/baXD0FqaDkb3KuXFjSKObCVZOUYeV8LHnJy/j7E25rebi PvWQ== 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=RHxKjX+qtZrEXQuBsKR3gC+KvcfYWNZ8OFGcMhA+wns=; b=F8YOo/jDcW/5MIa39RiA1bO9K1R/Ozt63sqLibNh1qEy1cHwjarqctvZYQisR6omPr 2Ovim36EsjZQMmaBsfPAIdOll7AzjA3GvLG0kEdmTw9UNL5pveio9G5YodGlFcgdIbQF D4fW4TjVuBK9ksRDxLutQvVycKFBQ1hsZYLygUmRqb9Ofe1swbQ5ielmjUucD9Ly0iHc T+mjRgzo3VIFyh5bJS5Tofj19zNaJhTug8LvqvT+Ptfl+WdpiL5hKYt6ChBhR5ayqzyo mpj+djE76wfxg9+hu3ADHj+Rf2AOPE/yxexU+XfXcW/EHYOXvzNSvWfelU/eU0rwUPAL kwKA== ARC-Authentication-Results: i=1; mx.google.com; dkim=fail header.i=@microchip.com header.s=mchp header.b="BJe/hCjj"; 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 w26si1702423ejs.63.2020.04.21.07.45.11; Tue, 21 Apr 2020 07:45:42 -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="BJe/hCjj"; 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 S1729366AbgDUOna (ORCPT + 99 others); Tue, 21 Apr 2020 10:43:30 -0400 Received: from esa5.microchip.iphmx.com ([216.71.150.166]:10382 "EHLO esa5.microchip.iphmx.com" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1729257AbgDUOnG (ORCPT ); Tue, 21 Apr 2020 10:43:06 -0400 DKIM-Signature: v=1; a=rsa-sha256; c=simple/simple; d=microchip.com; i=@microchip.com; q=dns/txt; s=mchp; t=1587480186; x=1619016186; h=from:to:cc:subject:date:message-id:in-reply-to: references:mime-version; bh=cV4Xbeo9JPYEAALbCGMZjIGvhQdcDLy7AnK61G5iajQ=; b=BJe/hCjjcUX2dPlCiriP/63mRMkd+hJ4KTJENpfwQDfopjiHd5yxQ0yX 8TnG/t5g+l2Q1gUMym/78CG8lVGZe+WSS5/7KR2IKnvlEzLoU/XQi3YGR TN78yWQVWHwDH0BQenqIfDZy9r5a7E/xQ6o8Rfa9vy0erVN34vUFEvG0R 1MCxN6vs0qAItTo0YItKVry25wJpwCwuuPvtGR2gzxAKPgCAxjlm5U7YQ N/eV/11zKBNz6ifZHDnaqFY1snZwfLz3fhLr4SRFJhPuy9mpPihW2N7PT FaA87T/orcV86L1jU0StwpjCO774BPRKkrfrknzaD+ABwPhFryxR0W4Qg w==; IronPort-SDR: oxH7qF6S3ibqJi/nsKp6+nlJ1PdKHWkCFDQOP06teIqrjm8BBg3qus7hKcE05iwKOsrLviOxx6 YCc4MB5BoSbDWkuyezs+j9A/5NPXedcxlYtH3I13VcnMpYf049JCFxuuvfDBNZrSg3v7zhyNXb 16pN6eJhkt2+taZubO74U6EO02DVwt/8HbaiitTWVAqRojR2X0Bn+4us26YIYsmaRvsRGBUsUY hhtadAeT4yVXFjTPgGCt7HyHyBQx4FL+BomXIsr9smF9otFUwMdap3fs96swuBN2vXAcS3xx0/ pFs= X-IronPort-AV: E=Sophos;i="5.72,410,1580799600"; d="scan'208";a="73284520" Received: from smtpout.microchip.com (HELO email.microchip.com) ([198.175.253.82]) by esa5.microchip.iphmx.com with ESMTP/TLS/AES256-SHA256; 21 Apr 2020 07:43:06 -0700 Received: from chn-vm-ex04.mchp-main.com (10.10.85.152) by chn-vm-ex02.mchp-main.com (10.10.85.144) with Microsoft SMTP Server (version=TLS1_2, cipher=TLS_ECDHE_RSA_WITH_AES_128_GCM_SHA256) id 15.1.1713.5; Tue, 21 Apr 2020 07:42:34 -0700 Received: from soft-dev3.microsemi.net (10.10.115.15) by chn-vm-ex04.mchp-main.com (10.10.85.152) with Microsoft SMTP Server id 15.1.1713.5 via Frontend Transport; Tue, 21 Apr 2020 07:43:01 -0700 From: Horatiu Vultur To: , , , , , , , , , , , CC: Horatiu Vultur Subject: [PATCH net-next v2 09/11] bridge: mrp: Implement netlink interface to configure MRP Date: Tue, 21 Apr 2020 16:37:50 +0200 Message-ID: <20200421143752.2248-10-horatiu.vultur@microchip.com> X-Mailer: git-send-email 2.17.1 In-Reply-To: <20200421143752.2248-1-horatiu.vultur@microchip.com> References: <20200421143752.2248-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 Implement netlink interface to configure MRP. The implementation will do sanity checks over the attributes and then eventually call the MRP interface. Signed-off-by: Horatiu Vultur --- net/bridge/br_mrp_netlink.c | 91 +++++++++++++++++++++++++++++++++++++ 1 file changed, 91 insertions(+) diff --git a/net/bridge/br_mrp_netlink.c b/net/bridge/br_mrp_netlink.c index b982db14bbf4..f4a84b1921b2 100644 --- a/net/bridge/br_mrp_netlink.c +++ b/net/bridge/br_mrp_netlink.c @@ -6,6 +6,97 @@ #include "br_private.h" #include "br_private_mrp.h" +static const struct nla_policy br_mrp_policy[IFLA_BRIDGE_MRP_MAX + 1] = { + [IFLA_BRIDGE_MRP_UNSPEC] = { .type = NLA_REJECT }, + [IFLA_BRIDGE_MRP_INSTANCE] = { .type = NLA_EXACT_LEN, + .len = sizeof(struct br_mrp_instance)}, + [IFLA_BRIDGE_MRP_PORT_STATE] = { .type = NLA_U32 }, + [IFLA_BRIDGE_MRP_PORT_ROLE] = { .type = NLA_EXACT_LEN, + .len = sizeof(struct br_mrp_port_role)}, + [IFLA_BRIDGE_MRP_RING_STATE] = { .type = NLA_EXACT_LEN, + .len = sizeof(struct br_mrp_ring_state)}, + [IFLA_BRIDGE_MRP_RING_ROLE] = { .type = NLA_EXACT_LEN, + .len = sizeof(struct br_mrp_ring_role)}, + [IFLA_BRIDGE_MRP_START_TEST] = { .type = NLA_EXACT_LEN, + .len = sizeof(struct br_mrp_start_test)}, +}; + +int br_mrp_parse(struct net_bridge *br, struct net_bridge_port *p, + struct nlattr *attr, int cmd, struct netlink_ext_ack *extack) +{ + struct nlattr *tb[IFLA_BRIDGE_MRP_MAX + 1]; + int err; + + if (br->stp_enabled != BR_NO_STP) { + NL_SET_ERR_MSG_MOD(extack, "MRP can't be enabled if STP is already enabled\n"); + return -EINVAL; + } + + err = nla_parse_nested(tb, IFLA_BRIDGE_MRP_MAX, attr, + NULL, extack); + if (err) + return err; + + if (tb[IFLA_BRIDGE_MRP_INSTANCE]) { + struct br_mrp_instance *instance = + nla_data(tb[IFLA_BRIDGE_MRP_INSTANCE]); + + if (cmd == RTM_SETLINK) + err = br_mrp_add(br, instance); + else + err = br_mrp_del(br, instance); + if (err) + return err; + } + + if (tb[IFLA_BRIDGE_MRP_PORT_STATE]) { + enum br_mrp_port_state_type state = + nla_get_u32(tb[IFLA_BRIDGE_MRP_PORT_STATE]); + + err = br_mrp_set_port_state(p, state); + if (err) + return err; + } + + if (tb[IFLA_BRIDGE_MRP_PORT_ROLE]) { + struct br_mrp_port_role *role = + nla_data(tb[IFLA_BRIDGE_MRP_PORT_ROLE]); + + err = br_mrp_set_port_role(p, role); + if (err) + return err; + } + + if (tb[IFLA_BRIDGE_MRP_RING_STATE]) { + struct br_mrp_ring_state *state = + nla_data(tb[IFLA_BRIDGE_MRP_RING_STATE]); + + err = br_mrp_set_ring_state(br, state); + if (err) + return err; + } + + if (tb[IFLA_BRIDGE_MRP_RING_ROLE]) { + struct br_mrp_ring_role *role = + nla_data(tb[IFLA_BRIDGE_MRP_RING_ROLE]); + + err = br_mrp_set_ring_role(br, role); + if (err) + return err; + } + + if (tb[IFLA_BRIDGE_MRP_START_TEST]) { + struct br_mrp_start_test *test = + nla_data(tb[IFLA_BRIDGE_MRP_START_TEST]); + + err = br_mrp_start_test(br, test); + if (err) + return err; + } + + return 0; +} + int br_mrp_port_open(struct net_device *dev, u8 loc) { struct net_bridge_port *p; -- 2.17.1