{"id":816262,"url":"http://patchwork.ozlabs.org/api/patches/816262/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/patch/20170920141516.1402-7-jiri@resnulli.us/","project":{"id":7,"url":"http://patchwork.ozlabs.org/api/projects/7/?format=json","name":"Linux network development","link_name":"netdev","list_id":"netdev.vger.kernel.org","list_email":"netdev@vger.kernel.org","web_url":null,"scm_url":null,"webscm_url":null,"list_archive_url":"","list_archive_url_format":"","commit_url_format":""},"msgid":"<20170920141516.1402-7-jiri@resnulli.us>","list_archive_url":null,"date":"2017-09-20T14:15:06","name":"[net-next,06/16] mlxsw: spectrum_switchdev: Attach mid id allocation to HW write","commit_ref":null,"pull_url":null,"state":"accepted","archived":true,"hash":"510046d08df7adff5f44268cbf285735ac56b0a3","submitter":{"id":15321,"url":"http://patchwork.ozlabs.org/api/people/15321/?format=json","name":"Jiri Pirko","email":"jiri@resnulli.us"},"delegate":{"id":34,"url":"http://patchwork.ozlabs.org/api/users/34/?format=json","username":"davem","first_name":"David","last_name":"Miller","email":"davem@davemloft.net"},"mbox":"http://patchwork.ozlabs.org/project/netdev/patch/20170920141516.1402-7-jiri@resnulli.us/mbox/","series":[{"id":4129,"url":"http://patchwork.ozlabs.org/api/series/4129/?format=json","web_url":"http://patchwork.ozlabs.org/project/netdev/list/?series=4129","date":"2017-09-20T14:15:00","name":"mlxsw: Multicast flood update","version":1,"mbox":"http://patchwork.ozlabs.org/series/4129/mbox/"}],"comments":"http://patchwork.ozlabs.org/api/patches/816262/comments/","check":"pending","checks":"http://patchwork.ozlabs.org/api/patches/816262/checks/","tags":{},"related":[],"headers":{"Return-Path":"<netdev-owner@vger.kernel.org>","X-Original-To":"patchwork-incoming@ozlabs.org","Delivered-To":"patchwork-incoming@ozlabs.org","Authentication-Results":["ozlabs.org;\n\tspf=none (mailfrom) smtp.mailfrom=vger.kernel.org\n\t(client-ip=209.132.180.67; helo=vger.kernel.org;\n\tenvelope-from=netdev-owner@vger.kernel.org;\n\treceiver=<UNKNOWN>)","ozlabs.org; dkim=pass (2048-bit key;\n\tunprotected) header.d=resnulli-us.20150623.gappssmtp.com\n\theader.i=@resnulli-us.20150623.gappssmtp.com\n\theader.b=\"F8WiKM2M\"; dkim-atps=neutral"],"Received":["from vger.kernel.org (vger.kernel.org [209.132.180.67])\n\tby ozlabs.org (Postfix) with ESMTP id 3xy1y52Chtz9s82\n\tfor <patchwork-incoming@ozlabs.org>;\n\tThu, 21 Sep 2017 00:16:29 +1000 (AEST)","(majordomo@vger.kernel.org) by vger.kernel.org via listexpand\n\tid S1751843AbdITOQW (ORCPT <rfc822;patchwork-incoming@ozlabs.org>);\n\tWed, 20 Sep 2017 10:16:22 -0400","from mail-wr0-f193.google.com ([209.85.128.193]:38286 \"EHLO\n\tmail-wr0-f193.google.com\" rhost-flags-OK-OK-OK-OK) by vger.kernel.org\n\twith ESMTP id S1751707AbdITOPY (ORCPT\n\t<rfc822;netdev@vger.kernel.org>); Wed, 20 Sep 2017 10:15:24 -0400","by mail-wr0-f193.google.com with SMTP id p37so1582796wrb.5\n\tfor <netdev@vger.kernel.org>; Wed, 20 Sep 2017 07:15:23 -0700 (PDT)","from localhost (ip-89-177-125-82.net.upcbroadband.cz.\n\t[89.177.125.82]) by smtp.gmail.com with ESMTPSA id\n\tz14sm1918628wre.35.2017.09.20.07.15.22\n\t(version=TLS1_2 cipher=ECDHE-RSA-CHACHA20-POLY1305 bits=256/256);\n\tWed, 20 Sep 2017 07:15:22 -0700 (PDT)"],"DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=resnulli-us.20150623.gappssmtp.com; s=20150623;\n\th=from:to:cc:subject:date:message-id:in-reply-to:references;\n\tbh=hGs7NjRjecSiRQgcah00/s5SpqdhydQhWEEi0OUkyGA=;\n\tb=F8WiKM2MdHmOxjfdXQWde1uA5xoEa7KFdVUmMq3pB2yRSL5g8uQ9N4rH/GZYtrH5wR\n\tAvCErt+LNb/SZnU85aL2AiFs2CL6zbYSOqneCH94KxFtr7mnSGze+YeVuTW9hzP8o8i/\n\tfqoM8EqaeRSwGQBoHdIADQF/tjHJU1Qzp3vuIkCbD6tfFvLIxByZnH49ncIAlT0Xgsy1\n\tTqOmzcaeqj2p31ThYkFD4lUC7DWdX+gSIhmm1dNWJY8JblD2c08N6SgAfxoOcux7BR9l\n\tOFSBR5PHLEEfGSF7Y+Gh19gjU4k+3r1Ym8uW31mEnQpk77upyit5B7mxW2ixS+ei0Opx\n\the6w==","X-Google-DKIM-Signature":"v=1; a=rsa-sha256; c=relaxed/relaxed;\n\td=1e100.net; s=20161025;\n\th=x-gm-message-state:from:to:cc:subject:date:message-id:in-reply-to\n\t:references;\n\tbh=hGs7NjRjecSiRQgcah00/s5SpqdhydQhWEEi0OUkyGA=;\n\tb=riNDRHCL7Z1nHzLBs5srk5/LH0jQzXzQlEECLLk5E8L7R6mqIMFHUHa6nqKCtlnb+L\n\to2f0gyXQ+PuruVDSfsAXWOL+XT6FuiGvHGpzIS33I3WKfsWs5tzSK2nl8vRFDKeU39Ds\n\trYFnq0Vj0WUz45I+XtvkRM6wPo+wKJQnJ+wtQlFmq+ZnlM8dpo5TWQHKK6r4S7+Mf0jr\n\tXpQHTJVlO4IExJBOaQaqIHGpXYAA8Mqn4gb02pBJvWZVZ7K73DQBBC4dAGira0YChs2C\n\t8cqkfCaw8EZh0OG2S08ITzvXYPRFwoOTSUVUYNLxjrQpyRywGXgntjpQ4m6625vouN65\n\tzoKA==","X-Gm-Message-State":"AHPjjUh/myv+bYNqK1JhD7cf1Yvy+EC2oqluoqExUlmbD6O8OSkwpNf9\n\t8A5oZ+5JDVg2mppr5PYT8nRaZMYB","X-Google-Smtp-Source":"AOwi7QAZeZqsi72qOYc9C3Fpiot9UqgX2ZZbKNBmAHY33N4PnWrwvMNSuyC5hjBU5rIFVE1TIvgMBg==","X-Received":"by 10.223.134.23 with SMTP id 23mr4724459wrv.93.1505916922687;\n\tWed, 20 Sep 2017 07:15:22 -0700 (PDT)","From":"Jiri Pirko <jiri@resnulli.us>","To":"netdev@vger.kernel.org","Cc":"davem@davemloft.net, nogahf@mellanox.com, idosch@mellanox.com,\n\tmlxsw@mellanox.com","Subject":"[patch net-next 06/16] mlxsw: spectrum_switchdev: Attach mid id\n\tallocation to HW write","Date":"Wed, 20 Sep 2017 16:15:06 +0200","Message-Id":"<20170920141516.1402-7-jiri@resnulli.us>","X-Mailer":"git-send-email 2.9.5","In-Reply-To":"<20170920141516.1402-1-jiri@resnulli.us>","References":"<20170920141516.1402-1-jiri@resnulli.us>","Sender":"netdev-owner@vger.kernel.org","Precedence":"bulk","List-ID":"<netdev.vger.kernel.org>","X-Mailing-List":"netdev@vger.kernel.org"},"content":"From: Nogah Frankel <nogahf@mellanox.com>\n\nAttach mid getting and releasing mid id to the HW write / remove, and add\na flag to indicate whether the mid is in the HW. It is done because mid id\nis also HW index to this mid.\nThis change allows adding in the following patches the ability to have a\nmid in the mdb cache but not in the HW. It will be useful for being able\nto disable the multicast.\nIt means that the mdb is being written / delete to the HW in the mid\nallocation / removing function, not after them.\n\nSigned-off-by: Nogah Frankel <nogahf@mellanox.com>\nSigned-off-by: Jiri Pirko <jiri@mellanox.com>\n---\n drivers/net/ethernet/mellanox/mlxsw/spectrum.h     |  1 +\n .../ethernet/mellanox/mlxsw/spectrum_switchdev.c   | 88 ++++++++++++++--------\n 2 files changed, 56 insertions(+), 33 deletions(-)","diff":"diff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h\nindex 6fd0afe..e907ec4 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum.h\n+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum.h\n@@ -94,6 +94,7 @@ struct mlxsw_sp_mid {\n \tunsigned char addr[ETH_ALEN];\n \tu16 fid;\n \tu16 mid;\n+\tbool in_hw;\n \tunsigned long *ports_in_mid; /* bits array */\n };\n \ndiff --git a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c\nindex 09ead97..9dd05d8 100644\n--- a/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c\n+++ b/drivers/net/ethernet/mellanox/mlxsw/spectrum_switchdev.c\n@@ -1260,6 +1260,42 @@ mlxsw_sp_mid *__mlxsw_sp_mc_get(struct mlxsw_sp_bridge_device *bridge_device,\n \treturn NULL;\n }\n \n+static bool\n+mlxsw_sp_mc_write_mdb_entry(struct mlxsw_sp *mlxsw_sp,\n+\t\t\t    struct mlxsw_sp_mid *mid)\n+{\n+\tu16 mid_idx;\n+\tint err;\n+\n+\tmid_idx = find_first_zero_bit(mlxsw_sp->bridge->mids_bitmap,\n+\t\t\t\t      MLXSW_SP_MID_MAX);\n+\tif (mid_idx == MLXSW_SP_MID_MAX)\n+\t\treturn false;\n+\n+\tmid->mid = mid_idx;\n+\terr = mlxsw_sp_port_smid_full_entry(mlxsw_sp, mid_idx);\n+\tif (err)\n+\t\treturn false;\n+\n+\terr = mlxsw_sp_port_mdb_op(mlxsw_sp, mid->addr, mid->fid, mid_idx,\n+\t\t\t\t   true);\n+\tif (err)\n+\t\treturn false;\n+\n+\tset_bit(mid_idx, mlxsw_sp->bridge->mids_bitmap);\n+\tmid->in_hw = true;\n+\treturn true;\n+}\n+\n+static int mlxsw_sp_mc_remove_mdb_entry(struct mlxsw_sp *mlxsw_sp,\n+\t\t\t\t\tstruct mlxsw_sp_mid *mid)\n+{\n+\tclear_bit(mid->mid, mlxsw_sp->bridge->mids_bitmap);\n+\tmid->in_hw = false;\n+\treturn mlxsw_sp_port_mdb_op(mlxsw_sp, mid->addr, mid->fid, mid->mid,\n+\t\t\t\t    false);\n+}\n+\n static struct\n mlxsw_sp_mid *__mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp,\n \t\t\t\t  struct mlxsw_sp_bridge_device *bridge_device,\n@@ -1268,12 +1304,6 @@ mlxsw_sp_mid *__mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp,\n {\n \tstruct mlxsw_sp_mid *mid;\n \tsize_t alloc_size;\n-\tu16 mid_idx;\n-\n-\tmid_idx = find_first_zero_bit(mlxsw_sp->bridge->mids_bitmap,\n-\t\t\t\t      MLXSW_SP_MID_MAX);\n-\tif (mid_idx == MLXSW_SP_MID_MAX)\n-\t\treturn NULL;\n \n \tmid = kzalloc(sizeof(*mid), GFP_KERNEL);\n \tif (!mid)\n@@ -1281,36 +1311,43 @@ mlxsw_sp_mid *__mlxsw_sp_mc_alloc(struct mlxsw_sp *mlxsw_sp,\n \n \talloc_size = sizeof(unsigned long) *\n \t\t     BITS_TO_LONGS(mlxsw_core_max_ports(mlxsw_sp->core));\n+\n \tmid->ports_in_mid = kzalloc(alloc_size, GFP_KERNEL);\n-\tif (!mid->ports_in_mid) {\n-\t\tkfree(mid);\n-\t\treturn NULL;\n-\t}\n+\tif (!mid->ports_in_mid)\n+\t\tgoto err_ports_in_mid_alloc;\n \n-\tset_bit(mid_idx, mlxsw_sp->bridge->mids_bitmap);\n \tether_addr_copy(mid->addr, addr);\n \tmid->fid = fid;\n-\tmid->mid = mid_idx;\n+\tmid->in_hw = false;\n+\tif (!mlxsw_sp_mc_write_mdb_entry(mlxsw_sp, mid))\n+\t\tgoto err_write_mdb_entry;\n+\n \tlist_add_tail(&mid->list, &bridge_device->mids_list);\n \n \treturn mid;\n+\n+err_write_mdb_entry:\n+\tkfree(mid->ports_in_mid);\n+err_ports_in_mid_alloc:\n+\tkfree(mid);\n+\treturn NULL;\n }\n \n static int mlxsw_sp_port_remove_from_mid(struct mlxsw_sp_port *mlxsw_sp_port,\n \t\t\t\t\t struct mlxsw_sp_mid *mid)\n {\n \tstruct mlxsw_sp *mlxsw_sp = mlxsw_sp_port->mlxsw_sp;\n+\tint err = 0;\n \n \tclear_bit(mlxsw_sp_port->local_port, mid->ports_in_mid);\n \tif (bitmap_empty(mid->ports_in_mid,\n \t\t\t mlxsw_core_max_ports(mlxsw_sp->core))) {\n+\t\terr = mlxsw_sp_mc_remove_mdb_entry(mlxsw_sp, mid);\n \t\tlist_del(&mid->list);\n-\t\tclear_bit(mid->mid, mlxsw_sp->bridge->mids_bitmap);\n \t\tkfree(mid->ports_in_mid);\n \t\tkfree(mid);\n-\t\treturn 1;\n \t}\n-\treturn 0;\n+\treturn err;\n }\n \n static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port,\n@@ -1324,7 +1361,6 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port,\n \tstruct mlxsw_sp_bridge_device *bridge_device;\n \tstruct mlxsw_sp_bridge_port *bridge_port;\n \tstruct mlxsw_sp_mid *mid;\n-\tbool is_new_mid = false;\n \tu16 fid_index;\n \tint err = 0;\n \n@@ -1352,8 +1388,6 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port,\n \t\t\tnetdev_err(dev, \"Unable to allocate MC group\\n\");\n \t\t\treturn -ENOMEM;\n \t\t}\n-\t\tis_new_mid = true;\n-\t\tmlxsw_sp_port_smid_full_entry(mlxsw_sp, mid->mid);\n \t}\n \tset_bit(mlxsw_sp_port->local_port, mid->ports_in_mid);\n \n@@ -1363,15 +1397,6 @@ static int mlxsw_sp_port_mdb_add(struct mlxsw_sp_port *mlxsw_sp_port,\n \t\tgoto err_out;\n \t}\n \n-\tif (is_new_mid) {\n-\t\terr = mlxsw_sp_port_mdb_op(mlxsw_sp, mdb->addr, fid_index,\n-\t\t\t\t\t   mid->mid, true);\n-\t\tif (err) {\n-\t\t\tnetdev_err(dev, \"Unable to set MC SFD\\n\");\n-\t\t\tgoto err_out;\n-\t\t}\n-\t}\n-\n \treturn 0;\n \n err_out:\n@@ -1481,12 +1506,9 @@ static int mlxsw_sp_port_mdb_del(struct mlxsw_sp_port *mlxsw_sp_port,\n \t\tnetdev_err(dev, \"Unable to remove port from SMID\\n\");\n \n \tmid_idx = mid->mid;\n-\tif (mlxsw_sp_port_remove_from_mid(mlxsw_sp_port, mid)) {\n-\t\terr = mlxsw_sp_port_mdb_op(mlxsw_sp, mdb->addr, fid_index,\n-\t\t\t\t\t   mid_idx, false);\n-\t\tif (err)\n-\t\t\tnetdev_err(dev, \"Unable to remove MC SFD\\n\");\n-\t}\n+\terr = mlxsw_sp_port_remove_from_mid(mlxsw_sp_port, mid);\n+\tif (err)\n+\t\tnetdev_err(dev, \"Unable to remove MC SFD\\n\");\n \n \treturn err;\n }\n","prefixes":["net-next","06/16"]}