All of lore.kernel.org
 help / color / mirror / Atom feed
From: Ido Schimmel <idosch@idosch.org>
To: Yevhen Orlov <yevhen.orlov@plvision.eu>
Cc: netdev@vger.kernel.org, stephen@networkplumber.org,
	andrew@lunn.ch, Volodymyr Mytnyk <volodymyr.mytnyk@plvision.eu>,
	Taras Chornyi <taras.chornyi@plvision.eu>,
	Mickey Rachamim <mickeyr@marvell.com>,
	Serhiy Pshyk <serhiy.pshyk@plvision.eu>,
	Taras Chornyi <tchornyi@marvell.com>,
	Oleksandr Mazur <oleksandr.mazur@plvision.eu>,
	"David S. Miller" <davem@davemloft.net>,
	Jakub Kicinski <kuba@kernel.org>,
	linux-kernel@vger.kernel.org
Subject: Re: [PATCH net-next v2 6/6] net: marvell: prestera: Implement initial inetaddr notifiers
Date: Thu, 30 Dec 2021 16:39:23 +0200	[thread overview]
Message-ID: <Yc3EmyltW1BVQv2n@shredder> (raw)
In-Reply-To: <20211227215233.31220-7-yevhen.orlov@plvision.eu>

On Mon, Dec 27, 2021 at 11:52:31PM +0200, Yevhen Orlov wrote:
> Add inetaddr notifiers to support add/del IPv4 address on switchdev
> port. We create TRAP on first address, added on port and delete TRAP,
> when last address removed.
> Currently, driver supports only regular port to became routed.
> Other port type support will be added later
> 
> Co-developed-by: Taras Chornyi <tchornyi@marvell.com>
> Signed-off-by: Taras Chornyi <tchornyi@marvell.com>
> Co-developed-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
> Signed-off-by: Oleksandr Mazur <oleksandr.mazur@plvision.eu>
> Signed-off-by: Yevhen Orlov <yevhen.orlov@plvision.eu>
> ---
> v1-->v2
> * Remove useless assigment in prestera_fix_tb_id
> ---
>  .../marvell/prestera/prestera_router.c        | 40 +++++++++++++++++++
>  1 file changed, 40 insertions(+)
> 
> diff --git a/drivers/net/ethernet/marvell/prestera/prestera_router.c b/drivers/net/ethernet/marvell/prestera/prestera_router.c
> index 0eb5f5e00e4e..483f0ba45ce0 100644
> --- a/drivers/net/ethernet/marvell/prestera/prestera_router.c
> +++ b/drivers/net/ethernet/marvell/prestera/prestera_router.c
> @@ -4,16 +4,31 @@
>  #include <linux/kernel.h>
>  #include <linux/types.h>
>  #include <linux/inetdevice.h>
> +#include <net/switchdev.h>
>  
>  #include "prestera.h"
>  #include "prestera_router_hw.h"
>  
> +/* This util to be used, to convert kernel rules for default vr in hw_vr */
> +static u32 prestera_fix_tb_id(u32 tb_id)
> +{
> +	if (tb_id == RT_TABLE_UNSPEC ||
> +	    tb_id == RT_TABLE_LOCAL ||
> +	    tb_id == RT_TABLE_DEFAULT)
> +		tb_id = RT_TABLE_MAIN;
> +
> +	return tb_id;
> +}
> +
>  static int __prestera_inetaddr_port_event(struct net_device *port_dev,
>  					  unsigned long event,
>  					  struct netlink_ext_ack *extack)
>  {
>  	struct prestera_port *port = netdev_priv(port_dev);
>  	int err;
> +	struct prestera_rif_entry *re;
> +	struct prestera_rif_entry_key re_key = {};
> +	u32 kern_tb_id;

Reverse xmas tree

>  
>  	err = prestera_is_valid_mac_addr(port, port_dev->dev_addr);
>  	if (err) {
> @@ -21,9 +36,34 @@ static int __prestera_inetaddr_port_event(struct net_device *port_dev,
>  		return err;
>  	}
>  
> +	kern_tb_id = l3mdev_fib_table(port_dev);
> +	re_key.iface.type = PRESTERA_IF_PORT_E;
> +	re_key.iface.dev_port.hw_dev_num  = port->dev_id;
> +	re_key.iface.dev_port.port_num  = port->hw_id;
> +	re = prestera_rif_entry_find(port->sw, &re_key);
> +
>  	switch (event) {
>  	case NETDEV_UP:
> +		if (re) {
> +			NL_SET_ERR_MSG_MOD(extack, "rif_entry already exist");

These messages are communicated to user space so use a message that is
more user friendly / informative

> +			return -EEXIST;
> +		}
> +		re = prestera_rif_entry_create(port->sw, &re_key,
> +					       prestera_fix_tb_id(kern_tb_id),
> +					       port_dev->dev_addr);
> +		if (!re) {
> +			NL_SET_ERR_MSG_MOD(extack, "Can't create rif_entry");
> +			return -EINVAL;
> +		}
> +		dev_hold(port_dev);

What is the purpose of this dev_hold()?

> +		break;
>  	case NETDEV_DOWN:
> +		if (!re) {
> +			NL_SET_ERR_MSG_MOD(extack, "rif_entry not exist");
> +			return -EEXIST;
> +		}
> +		prestera_rif_entry_destroy(port->sw, re);
> +		dev_put(port_dev);
>  		break;
>  	}
>  
> -- 
> 2.17.1
> 

  reply	other threads:[~2021-12-30 14:39 UTC|newest]

Thread overview: 18+ messages / expand[flat|nested]  mbox.gz  Atom feed  top
2021-12-27 21:52 [PATCH net-next v2 0/6] prestera: add basic router driver support Yevhen Orlov
2021-12-27 21:52 ` [PATCH net-next v2 1/6] net: marvell: prestera: add virtual router ABI Yevhen Orlov
2021-12-30 13:41   ` Ido Schimmel
2021-12-27 21:52 ` [PATCH net-next v2 2/6] net: marvell: prestera: Add router interface ABI Yevhen Orlov
2021-12-30 13:44   ` Ido Schimmel
2022-01-07  2:15     ` Yevhen Orlov
2021-12-27 21:52 ` [PATCH net-next v2 3/6] net: marvell: prestera: Add prestera router infra Yevhen Orlov
2021-12-30 13:48   ` Ido Schimmel
2021-12-27 21:52 ` [PATCH net-next v2 4/6] net: marvell: prestera: add hardware router objects accounting Yevhen Orlov
2021-12-30 14:19   ` Ido Schimmel
2021-12-27 21:52 ` [PATCH net-next v2 5/6] net: marvell: prestera: Register inetaddr stub notifiers Yevhen Orlov
2021-12-30 14:34   ` Ido Schimmel
2022-01-07  1:42     ` Yevhen Orlov
2022-01-07 13:43       ` Andrew Lunn
2022-01-11  1:00         ` Yevhen Orlov
2021-12-27 21:52 ` [PATCH net-next v2 6/6] net: marvell: prestera: Implement initial inetaddr notifiers Yevhen Orlov
2021-12-30 14:39   ` Ido Schimmel [this message]
2022-01-06  4:31     ` Yevhen Orlov

Reply instructions:

You may reply publicly to this message via plain-text email
using any one of the following methods:

* Save the following mbox file, import it into your mail client,
  and reply-to-all from there: mbox

  Avoid top-posting and favor interleaved quoting:
  https://en.wikipedia.org/wiki/Posting_style#Interleaved_style

* Reply using the --to, --cc, and --in-reply-to
  switches of git-send-email(1):

  git send-email \
    --in-reply-to=Yc3EmyltW1BVQv2n@shredder \
    --to=idosch@idosch.org \
    --cc=andrew@lunn.ch \
    --cc=davem@davemloft.net \
    --cc=kuba@kernel.org \
    --cc=linux-kernel@vger.kernel.org \
    --cc=mickeyr@marvell.com \
    --cc=netdev@vger.kernel.org \
    --cc=oleksandr.mazur@plvision.eu \
    --cc=serhiy.pshyk@plvision.eu \
    --cc=stephen@networkplumber.org \
    --cc=taras.chornyi@plvision.eu \
    --cc=tchornyi@marvell.com \
    --cc=volodymyr.mytnyk@plvision.eu \
    --cc=yevhen.orlov@plvision.eu \
    /path/to/YOUR_REPLY

  https://kernel.org/pub/software/scm/git/docs/git-send-email.html

* If your mail client supports setting the In-Reply-To header
  via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line before the message body.
This is an external index of several public inboxes,
see mirroring instructions on how to clone and mirror
all data and code used by this external index.