Netdev List
 help / color / mirror / Atom feed
* [PATCH net-next v2 4/6] nfp: register ports as devlink ports
From: Jakub Kicinski @ 2017-05-26  8:03 UTC (permalink / raw)
  To: netdev; +Cc: jiri, oss-drivers, Jakub Kicinski
In-Reply-To: <20170526080336.32689-1-jakub.kicinski@netronome.com>

Extend nfp_port to contain devlink_port structures.  Register the
ports to allow users inspecting device ports.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_devlink.c  | 45 +++++++++++++++++++++++
 drivers/net/ethernet/netronome/nfp/nfp_net_main.c | 13 +++++++
 drivers/net/ethernet/netronome/nfp/nfp_port.h     |  8 ++++
 3 files changed, 66 insertions(+)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index a8a52b3ff42b..2cfcb66b04bb 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -31,9 +31,54 @@
  * SOFTWARE.
  */
 
+#include <linux/rtnetlink.h>
 #include <net/devlink.h>
 
+#include "nfpcore/nfp_nsp.h"
+#include "nfp_app.h"
 #include "nfp_main.h"
+#include "nfp_port.h"
+
+static int
+nfp_devlink_fill_eth_port(struct nfp_port *port,
+			  struct nfp_eth_table_port *copy)
+{
+	struct nfp_eth_table_port *eth_port;
+
+	eth_port = __nfp_port_get_eth_port(port);
+	if (!eth_port)
+		return -EINVAL;
+
+	memcpy(copy, eth_port, sizeof(*eth_port));
+
+	return 0;
+}
 
 const struct devlink_ops nfp_devlink_ops = {
 };
+
+int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
+{
+	struct nfp_eth_table_port eth_port;
+	struct devlink *devlink;
+	int ret;
+
+	rtnl_lock();
+	ret = nfp_devlink_fill_eth_port(port, &eth_port);
+	rtnl_unlock();
+	if (ret)
+		return ret;
+
+	devlink_port_type_eth_set(&port->dl_port, port->netdev);
+	if (eth_port.is_split)
+		devlink_port_split_set(&port->dl_port, eth_port.label_port);
+
+	devlink = priv_to_devlink(app->pf);
+
+	return devlink_port_register(devlink, &port->dl_port, port->eth_id);
+}
+
+void nfp_devlink_port_unregister(struct nfp_port *port)
+{
+	devlink_port_unregister(&port->dl_port);
+}
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index b0a6ec4fe097..b733c97677fb 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -354,9 +354,20 @@ nfp_net_pf_init_vnic(struct nfp_pf *pf, struct nfp_net *nn, unsigned int id)
 
 	nfp_net_debugfs_vnic_add(nn, pf->ddir, id);
 
+	if (nn->port) {
+		err = nfp_devlink_port_register(pf->app, nn->port);
+		if (err)
+			goto err_dfs_clean;
+	}
+
 	nfp_net_info(nn);
 
 	return 0;
+
+err_dfs_clean:
+	nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
+	nfp_net_clean(nn);
+	return err;
 }
 
 static int
@@ -420,6 +431,8 @@ nfp_net_pf_alloc_vnics(struct nfp_pf *pf, void __iomem *ctrl_bar,
 
 static void nfp_net_pf_clean_vnic(struct nfp_pf *pf, struct nfp_net *nn)
 {
+	if (nn->port)
+		nfp_devlink_port_unregister(nn->port);
 	nfp_net_debugfs_dir_clean(&nn->debugfs_dir);
 	nfp_net_clean(nn);
 }
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.h b/drivers/net/ethernet/netronome/nfp/nfp_port.h
index 641617de41cc..36a540b514be 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.h
@@ -34,6 +34,8 @@
 #ifndef _NFP_PORT_H_
 #define _NFP_PORT_H_
 
+#include <net/devlink.h>
+
 struct net_device;
 struct nfp_app;
 struct nfp_port;
@@ -66,6 +68,7 @@ enum nfp_port_flags {
  * @type:	what port type does the entity represent
  * @flags:	port flags
  * @app:	backpointer to the app structure
+ * @dl_port:	devlink port structure
  * @eth_id:	for %NFP_PORT_PHYS_PORT port ID in NFP enumeration scheme
  * @eth_port:	for %NFP_PORT_PHYS_PORT translated ETH Table port entry
  * @port_list:	entry on pf's list of ports
@@ -78,6 +81,8 @@ struct nfp_port {
 
 	struct nfp_app *app;
 
+	struct devlink_port dl_port;
+
 	unsigned int eth_id;
 	struct nfp_eth_table_port *eth_port;
 
@@ -99,4 +104,7 @@ void nfp_port_free(struct nfp_port *port);
 int nfp_net_refresh_eth_port(struct nfp_port *port);
 void nfp_net_refresh_port_table(struct nfp_port *port);
 
+int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port);
+void nfp_devlink_port_unregister(struct nfp_port *port);
+
 #endif
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next v2 5/6] nfp: calculate total port lanes for split
From: Jakub Kicinski @ 2017-05-26  8:03 UTC (permalink / raw)
  To: netdev; +Cc: jiri, oss-drivers, Jakub Kicinski
In-Reply-To: <20170526080336.32689-1-jakub.kicinski@netronome.com>

For port splitting we will need to know the total number of lanes
in a port.  Calculate that based on eth_table information.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h     |  3 +++
 drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c | 11 ++++++-----
 2 files changed, 9 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
index 36b21e4dc56d..84a1d20adae1 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
@@ -96,6 +96,7 @@ enum nfp_eth_aneg {
  * @override_changed: is media reconfig pending?
  *
  * @port_type:	one of %PORT_* defines for ethtool
+ * @port_lanes:	total number of lanes on the port (sum of lanes of all subports)
  * @is_split:	is interface part of a split port
  */
 struct nfp_eth_table {
@@ -127,6 +128,8 @@ struct nfp_eth_table {
 		/* Computed fields */
 		u8 port_type;
 
+		unsigned int port_lanes;
+
 		bool is_split;
 	} ports[0];
 };
diff --git a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
index 639438d8313a..b0f8785c064f 100644
--- a/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
+++ b/drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c
@@ -186,17 +186,19 @@ nfp_eth_port_translate(struct nfp_nsp *nsp, const union eth_table_entry *src,
 }
 
 static void
-nfp_eth_mark_split_ports(struct nfp_cpp *cpp, struct nfp_eth_table *table)
+nfp_eth_calc_port_geometry(struct nfp_cpp *cpp, struct nfp_eth_table *table)
 {
 	unsigned int i, j;
 
 	for (i = 0; i < table->count; i++)
 		for (j = 0; j < table->count; j++) {
-			if (i == j)
-				continue;
 			if (table->ports[i].label_port !=
 			    table->ports[j].label_port)
 				continue;
+			table->ports[i].port_lanes += table->ports[j].lanes;
+
+			if (i == j)
+				continue;
 			if (table->ports[i].label_subport ==
 			    table->ports[j].label_subport)
 				nfp_warn(cpp,
@@ -205,7 +207,6 @@ nfp_eth_mark_split_ports(struct nfp_cpp *cpp, struct nfp_eth_table *table)
 					 table->ports[i].label_subport);
 
 			table->ports[i].is_split = true;
-			break;
 		}
 }
 
@@ -289,7 +290,7 @@ __nfp_eth_read_ports(struct nfp_cpp *cpp, struct nfp_nsp *nsp)
 			nfp_eth_port_translate(nsp, &entries[i], i,
 					       &table->ports[j++]);
 
-	nfp_eth_mark_split_ports(cpp, table);
+	nfp_eth_calc_port_geometry(cpp, table);
 	for (i = 0; i < table->count; i++)
 		nfp_eth_calc_port_type(cpp, &table->ports[i]);
 
-- 
2.11.0

^ permalink raw reply related

* [PATCH net-next v2 6/6] nfp: support port splitting via devlink
From: Jakub Kicinski @ 2017-05-26  8:03 UTC (permalink / raw)
  To: netdev; +Cc: jiri, oss-drivers, Jakub Kicinski
In-Reply-To: <20170526080336.32689-1-jakub.kicinski@netronome.com>

Add support for configuring port split with devlink.  Add devlink
callbacks to validate requested config and call NSP helpers.
Getting the right nfp_port structure can be done with simple iteration.

Signed-off-by: Jakub Kicinski <jakub.kicinski@netronome.com>
Reviewed-by: Simon Horman <simon.horman@netronome.com>
---
 drivers/net/ethernet/netronome/nfp/nfp_devlink.c  | 97 +++++++++++++++++++++++
 drivers/net/ethernet/netronome/nfp/nfp_net_main.c | 23 ++++--
 drivers/net/ethernet/netronome/nfp/nfp_port.c     | 19 +++++
 drivers/net/ethernet/netronome/nfp/nfp_port.h     |  4 +
 4 files changed, 136 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
index 2cfcb66b04bb..2609a0f28e81 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_devlink.c
@@ -54,7 +54,104 @@ nfp_devlink_fill_eth_port(struct nfp_port *port,
 	return 0;
 }
 
+static int
+nfp_devlink_fill_eth_port_from_id(struct nfp_pf *pf, unsigned int port_index,
+				  struct nfp_eth_table_port *copy)
+{
+	struct nfp_port *port;
+
+	port = nfp_port_from_id(pf, NFP_PORT_PHYS_PORT, port_index);
+
+	return nfp_devlink_fill_eth_port(port, copy);
+}
+
+static int
+nfp_devlink_set_lanes(struct nfp_pf *pf, unsigned int idx, unsigned int lanes)
+{
+	struct nfp_nsp *nsp;
+	int ret;
+
+	nsp = nfp_eth_config_start(pf->cpp, idx);
+	if (IS_ERR(nsp))
+		return PTR_ERR(nsp);
+
+	ret = __nfp_eth_set_split(nsp, lanes);
+	if (ret) {
+		nfp_eth_config_cleanup_end(nsp);
+		return ret;
+	}
+
+	ret = nfp_eth_config_commit_end(nsp);
+	if (ret < 0)
+		return ret;
+	if (ret) /* no change */
+		return 0;
+
+	return nfp_net_refresh_port_table_sync(pf);
+}
+
+static int
+nfp_devlink_port_split(struct devlink *devlink, unsigned int port_index,
+		       unsigned int count)
+{
+	struct nfp_pf *pf = devlink_priv(devlink);
+	struct nfp_eth_table_port eth_port;
+	int ret;
+
+	if (count < 2)
+		return -EINVAL;
+
+	mutex_lock(&pf->lock);
+
+	rtnl_lock();
+	ret = nfp_devlink_fill_eth_port_from_id(pf, port_index, &eth_port);
+	rtnl_unlock();
+	if (ret)
+		goto out;
+
+	if (eth_port.is_split || eth_port.port_lanes % count) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = nfp_devlink_set_lanes(pf, eth_port.index,
+				    eth_port.port_lanes / count);
+out:
+	mutex_unlock(&pf->lock);
+
+	return ret;
+}
+
+static int
+nfp_devlink_port_unsplit(struct devlink *devlink, unsigned int port_index)
+{
+	struct nfp_pf *pf = devlink_priv(devlink);
+	struct nfp_eth_table_port eth_port;
+	int ret;
+
+	mutex_lock(&pf->lock);
+
+	rtnl_lock();
+	ret = nfp_devlink_fill_eth_port_from_id(pf, port_index, &eth_port);
+	rtnl_unlock();
+	if (ret)
+		goto out;
+
+	if (!eth_port.is_split) {
+		ret = -EINVAL;
+		goto out;
+	}
+
+	ret = nfp_devlink_set_lanes(pf, eth_port.index, eth_port.port_lanes);
+out:
+	mutex_unlock(&pf->lock);
+
+	return ret;
+}
+
 const struct devlink_ops nfp_devlink_ops = {
+	.port_split		= nfp_devlink_port_split,
+	.port_unsplit		= nfp_devlink_port_unsplit,
 };
 
 int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
index b733c97677fb..388759e047d8 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_net_main.c
@@ -43,6 +43,7 @@
 #include <linux/etherdevice.h>
 #include <linux/kernel.h>
 #include <linux/init.h>
+#include <linux/lockdep.h>
 #include <linux/pci.h>
 #include <linux/pci_regs.h>
 #include <linux/msi.h>
@@ -561,19 +562,17 @@ nfp_net_eth_port_update(struct nfp_cpp *cpp, struct nfp_port *port,
 	return 0;
 }
 
-static void nfp_net_refresh_vnics(struct work_struct *work)
+int nfp_net_refresh_port_table_sync(struct nfp_pf *pf)
 {
-	struct nfp_pf *pf = container_of(work, struct nfp_pf,
-					 port_refresh_work);
 	struct nfp_eth_table *eth_table;
 	struct nfp_net *nn, *next;
 	struct nfp_port *port;
 
-	mutex_lock(&pf->lock);
+	lockdep_assert_held(&pf->lock);
 
 	/* Check for nfp_net_pci_remove() racing against us */
 	if (list_empty(&pf->vnics))
-		goto out;
+		return 0;
 
 	/* Update state of all ports */
 	rtnl_lock();
@@ -587,7 +586,7 @@ static void nfp_net_refresh_vnics(struct work_struct *work)
 				set_bit(NFP_PORT_CHANGED, &port->flags);
 		rtnl_unlock();
 		nfp_err(pf->cpp, "Error refreshing port config!\n");
-		goto out;
+		return -EIO;
 	}
 
 	list_for_each_entry(port, &pf->ports, port_list)
@@ -608,7 +607,17 @@ static void nfp_net_refresh_vnics(struct work_struct *work)
 
 	if (list_empty(&pf->vnics))
 		nfp_net_pci_remove_finish(pf);
-out:
+
+	return 0;
+}
+
+static void nfp_net_refresh_vnics(struct work_struct *work)
+{
+	struct nfp_pf *pf = container_of(work, struct nfp_pf,
+					 port_refresh_work);
+
+	mutex_lock(&pf->lock);
+	nfp_net_refresh_port_table_sync(pf);
 	mutex_unlock(&pf->lock);
 }
 
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.c b/drivers/net/ethernet/netronome/nfp/nfp_port.c
index 3beed4167e2f..a17410ac01ab 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.c
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.c
@@ -31,6 +31,8 @@
  * SOFTWARE.
  */
 
+#include <linux/lockdep.h>
+
 #include "nfpcore/nfp_nsp.h"
 #include "nfp_app.h"
 #include "nfp_main.h"
@@ -48,6 +50,23 @@ struct nfp_port *nfp_port_from_netdev(struct net_device *netdev)
 	return nn->port;
 }
 
+struct nfp_port *
+nfp_port_from_id(struct nfp_pf *pf, enum nfp_port_type type, unsigned int id)
+{
+	struct nfp_port *port;
+
+	lockdep_assert_held(&pf->lock);
+
+	if (type != NFP_PORT_PHYS_PORT)
+		return NULL;
+
+	list_for_each_entry(port, &pf->ports, port_list)
+		if (port->eth_id == id)
+			return port;
+
+	return NULL;
+}
+
 struct nfp_eth_table_port *__nfp_port_get_eth_port(struct nfp_port *port)
 {
 	if (!port)
diff --git a/drivers/net/ethernet/netronome/nfp/nfp_port.h b/drivers/net/ethernet/netronome/nfp/nfp_port.h
index 36a540b514be..4d1a9b3fed41 100644
--- a/drivers/net/ethernet/netronome/nfp/nfp_port.h
+++ b/drivers/net/ethernet/netronome/nfp/nfp_port.h
@@ -38,6 +38,7 @@
 
 struct net_device;
 struct nfp_app;
+struct nfp_pf;
 struct nfp_port;
 
 /**
@@ -90,6 +91,8 @@ struct nfp_port {
 };
 
 struct nfp_port *nfp_port_from_netdev(struct net_device *netdev);
+struct nfp_port *
+nfp_port_from_id(struct nfp_pf *pf, enum nfp_port_type type, unsigned int id);
 struct nfp_eth_table_port *__nfp_port_get_eth_port(struct nfp_port *port);
 struct nfp_eth_table_port *nfp_port_get_eth_port(struct nfp_port *port);
 
@@ -103,6 +106,7 @@ void nfp_port_free(struct nfp_port *port);
 
 int nfp_net_refresh_eth_port(struct nfp_port *port);
 void nfp_net_refresh_port_table(struct nfp_port *port);
+int nfp_net_refresh_port_table_sync(struct nfp_pf *pf);
 
 int nfp_devlink_port_register(struct nfp_app *app, struct nfp_port *port);
 void nfp_devlink_port_unregister(struct nfp_port *port);
-- 
2.11.0

^ permalink raw reply related

* Re: [PATCH 1/5] MIPS: Optimize uasm insn lookup.
From: Matt Redfearn @ 2017-05-26  8:07 UTC (permalink / raw)
  To: David Daney, Alexei Starovoitov, Daniel Borkmann, netdev,
	linux-kernel, linux-mips, ralf
In-Reply-To: <20170526003826.10834-2-david.daney@cavium.com>

Hi David,


On 26/05/17 01:38, David Daney wrote:
> Instead of doing a linear search through the insn_table for each
> instruction, use the opcode as direct index into the table.  This will
> give constant time lookup performance as the number of supported
> opcodes increases.  Make the tables const as they are only ever read.
> For uasm-mips.c sort the table alphabetically, and remove duplicate
> entries, uasm-micromips.c was already sorted and duplicate free.
> There is a small savings in object size as struct insn loses a field:
>
> $ size arch/mips/mm/uasm-mips.o arch/mips/mm/uasm-mips.o.save
>     text	   data	    bss	    dec	    hex	filename
>    10040	      0	      0	  10040	   2738	arch/mips/mm/uasm-mips.o
>     9240	   1120	      0	  10360	   2878	arch/mips/mm/uasm-mips.o.save
>
> Signed-off-by: David Daney <david.daney@cavium.com>
> ---
>   arch/mips/mm/uasm-micromips.c | 188 ++++++++++++++++++------------------
>   arch/mips/mm/uasm-mips.c      | 217 +++++++++++++++++++++---------------------
>   arch/mips/mm/uasm.c           |   3 +-
>   3 files changed, 199 insertions(+), 209 deletions(-)
>
> diff --git a/arch/mips/mm/uasm-micromips.c b/arch/mips/mm/uasm-micromips.c
> index 277cf52..da6de62 100644
> --- a/arch/mips/mm/uasm-micromips.c
> +++ b/arch/mips/mm/uasm-micromips.c
> @@ -40,93 +40,92 @@
>   
>   #include "uasm.c"
>   
> -static struct insn insn_table_MM[] = {
> -	{ insn_addu, M(mm_pool32a_op, 0, 0, 0, 0, mm_addu32_op), RT | RS | RD },
> -	{ insn_addiu, M(mm_addiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM },
> -	{ insn_and, M(mm_pool32a_op, 0, 0, 0, 0, mm_and_op), RT | RS | RD },
> -	{ insn_andi, M(mm_andi32_op, 0, 0, 0, 0, 0), RT | RS | UIMM },
> -	{ insn_beq, M(mm_beq32_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
> -	{ insn_beql, 0, 0 },
> -	{ insn_bgez, M(mm_pool32i_op, mm_bgez_op, 0, 0, 0, 0), RS | BIMM },
> -	{ insn_bgezl, 0, 0 },
> -	{ insn_bltz, M(mm_pool32i_op, mm_bltz_op, 0, 0, 0, 0), RS | BIMM },
> -	{ insn_bltzl, 0, 0 },
> -	{ insn_bne, M(mm_bne32_op, 0, 0, 0, 0, 0), RT | RS | BIMM },
> -	{ insn_cache, M(mm_pool32b_op, 0, 0, mm_cache_func, 0, 0), RT | RS | SIMM },
> -	{ insn_cfc1, M(mm_pool32f_op, 0, 0, 0, mm_cfc1_op, mm_32f_73_op), RT | RS },
> -	{ insn_cfcmsa, M(mm_pool32s_op, 0, msa_cfc_op, 0, 0, mm_32s_elm_op), RD | RE },
> -	{ insn_ctc1, M(mm_pool32f_op, 0, 0, 0, mm_ctc1_op, mm_32f_73_op), RT | RS },
> -	{ insn_ctcmsa, M(mm_pool32s_op, 0, msa_ctc_op, 0, 0, mm_32s_elm_op), RD | RE },
> -	{ insn_daddu, 0, 0 },
> -	{ insn_daddiu, 0, 0 },
> -	{ insn_di, M(mm_pool32a_op, 0, 0, 0, mm_di_op, mm_pool32axf_op), RS },
> -	{ insn_divu, M(mm_pool32a_op, 0, 0, 0, mm_divu_op, mm_pool32axf_op), RT | RS },
> -	{ insn_dmfc0, 0, 0 },
> -	{ insn_dmtc0, 0, 0 },
> -	{ insn_dsll, 0, 0 },
> -	{ insn_dsll32, 0, 0 },
> -	{ insn_dsra, 0, 0 },
> -	{ insn_dsrl, 0, 0 },
> -	{ insn_dsrl32, 0, 0 },
> -	{ insn_drotr, 0, 0 },
> -	{ insn_drotr32, 0, 0 },
> -	{ insn_dsubu, 0, 0 },
> -	{ insn_eret, M(mm_pool32a_op, 0, 0, 0, mm_eret_op, mm_pool32axf_op), 0 },
> -	{ insn_ins, M(mm_pool32a_op, 0, 0, 0, 0, mm_ins_op), RT | RS | RD | RE },
> -	{ insn_ext, M(mm_pool32a_op, 0, 0, 0, 0, mm_ext_op), RT | RS | RD | RE },
> -	{ insn_j, M(mm_j32_op, 0, 0, 0, 0, 0), JIMM },
> -	{ insn_jal, M(mm_jal32_op, 0, 0, 0, 0, 0), JIMM },
> -	{ insn_jalr, M(mm_pool32a_op, 0, 0, 0, mm_jalr_op, mm_pool32axf_op), RT | RS },
> -	{ insn_jr, M(mm_pool32a_op, 0, 0, 0, mm_jalr_op, mm_pool32axf_op), RS },
> -	{ insn_lb, M(mm_lb32_op, 0, 0, 0, 0, 0), RT | RS | SIMM },
> -	{ insn_ld, 0, 0 },
> -	{ insn_lh, M(mm_lh32_op, 0, 0, 0, 0, 0), RS | RS | SIMM },
> -	{ insn_ll, M(mm_pool32c_op, 0, 0, (mm_ll_func << 1), 0, 0), RS | RT | SIMM },
> -	{ insn_lld, 0, 0 },
> -	{ insn_lui, M(mm_pool32i_op, mm_lui_op, 0, 0, 0, 0), RS | SIMM },
> -	{ insn_lw, M(mm_lw32_op, 0, 0, 0, 0, 0), RT | RS | SIMM },
> -	{ insn_mfc0, M(mm_pool32a_op, 0, 0, 0, mm_mfc0_op, mm_pool32axf_op), RT | RS | RD },
> -	{ insn_mfhi, M(mm_pool32a_op, 0, 0, 0, mm_mfhi32_op, mm_pool32axf_op), RS },
> -	{ insn_mflo, M(mm_pool32a_op, 0, 0, 0, mm_mflo32_op, mm_pool32axf_op), RS },
> -	{ insn_mtc0, M(mm_pool32a_op, 0, 0, 0, mm_mtc0_op, mm_pool32axf_op), RT | RS | RD },
> -	{ insn_mthi, M(mm_pool32a_op, 0, 0, 0, mm_mthi32_op, mm_pool32axf_op), RS },
> -	{ insn_mtlo, M(mm_pool32a_op, 0, 0, 0, mm_mtlo32_op, mm_pool32axf_op), RS },
> -	{ insn_mul, M(mm_pool32a_op, 0, 0, 0, 0, mm_mul_op), RT | RS | RD },
> -	{ insn_or, M(mm_pool32a_op, 0, 0, 0, 0, mm_or32_op), RT | RS | RD },
> -	{ insn_ori, M(mm_ori32_op, 0, 0, 0, 0, 0), RT | RS | UIMM },
> -	{ insn_pref, M(mm_pool32c_op, 0, 0, (mm_pref_func << 1), 0, 0), RT | RS | SIMM },
> -	{ insn_rfe, 0, 0 },
> -	{ insn_sc, M(mm_pool32c_op, 0, 0, (mm_sc_func << 1), 0, 0), RT | RS | SIMM },
> -	{ insn_scd, 0, 0 },
> -	{ insn_sd, 0, 0 },
> -	{ insn_sll, M(mm_pool32a_op, 0, 0, 0, 0, mm_sll32_op), RT | RS | RD },
> -	{ insn_sllv, M(mm_pool32a_op, 0, 0, 0, 0, mm_sllv32_op), RT | RS | RD },
> -	{ insn_slt, M(mm_pool32a_op, 0, 0, 0, 0, mm_slt_op), RT | RS | RD },
> -	{ insn_sltiu, M(mm_sltiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM },
> -	{ insn_sltu, M(mm_pool32a_op, 0, 0, 0, 0, mm_sltu_op), RT | RS | RD },
> -	{ insn_sra, M(mm_pool32a_op, 0, 0, 0, 0, mm_sra_op), RT | RS | RD },
> -	{ insn_srl, M(mm_pool32a_op, 0, 0, 0, 0, mm_srl32_op), RT | RS | RD },
> -	{ insn_srlv, M(mm_pool32a_op, 0, 0, 0, 0, mm_srlv32_op), RT | RS | RD },
> -	{ insn_rotr, M(mm_pool32a_op, 0, 0, 0, 0, mm_rotr_op), RT | RS | RD },
> -	{ insn_subu, M(mm_pool32a_op, 0, 0, 0, 0, mm_subu32_op), RT | RS | RD },
> -	{ insn_sw, M(mm_sw32_op, 0, 0, 0, 0, 0), RT | RS | SIMM },
> -	{ insn_sync, M(mm_pool32a_op, 0, 0, 0, mm_sync_op, mm_pool32axf_op), RS },
> -	{ insn_tlbp, M(mm_pool32a_op, 0, 0, 0, mm_tlbp_op, mm_pool32axf_op), 0 },
> -	{ insn_tlbr, M(mm_pool32a_op, 0, 0, 0, mm_tlbr_op, mm_pool32axf_op), 0 },
> -	{ insn_tlbwi, M(mm_pool32a_op, 0, 0, 0, mm_tlbwi_op, mm_pool32axf_op), 0 },
> -	{ insn_tlbwr, M(mm_pool32a_op, 0, 0, 0, mm_tlbwr_op, mm_pool32axf_op), 0 },
> -	{ insn_wait, M(mm_pool32a_op, 0, 0, 0, mm_wait_op, mm_pool32axf_op), SCIMM },
> -	{ insn_wsbh, M(mm_pool32a_op, 0, 0, 0, mm_wsbh_op, mm_pool32axf_op), RT | RS },
> -	{ insn_xor, M(mm_pool32a_op, 0, 0, 0, 0, mm_xor32_op), RT | RS | RD },
> -	{ insn_xori, M(mm_xori32_op, 0, 0, 0, 0, 0), RT | RS | UIMM },
> -	{ insn_dins, 0, 0 },
> -	{ insn_dinsm, 0, 0 },
> -	{ insn_syscall, M(mm_pool32a_op, 0, 0, 0, mm_syscall_op, mm_pool32axf_op), SCIMM},
> -	{ insn_bbit0, 0, 0 },
> -	{ insn_bbit1, 0, 0 },
> -	{ insn_lwx, 0, 0 },
> -	{ insn_ldx, 0, 0 },
> -	{ insn_invalid, 0, 0 }
> +static struct insn insn_table_MM[insn_invalid] = {

^ You could make this const too, like you have the one in uasm-mips.c.

Thanks,
Matt

> +	[insn_addu]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_addu32_op), RT | RS | RD},
> +	[insn_addiu]	= {M(mm_addiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM},
> +	[insn_and]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_and_op), RT | RS | RD},
> +	[insn_andi]	= {M(mm_andi32_op, 0, 0, 0, 0, 0), RT | RS | UIMM},
> +	[insn_beq]	= {M(mm_beq32_op, 0, 0, 0, 0, 0), RS | RT | BIMM},
> +	[insn_beql]	= {0, 0},
> +	[insn_bgez]	= {M(mm_pool32i_op, mm_bgez_op, 0, 0, 0, 0), RS | BIMM},
> +	[insn_bgezl]	= {0, 0},
> +	[insn_bltz]	= {M(mm_pool32i_op, mm_bltz_op, 0, 0, 0, 0), RS | BIMM},
> +	[insn_bltzl]	= {0, 0},
> +	[insn_bne]	= {M(mm_bne32_op, 0, 0, 0, 0, 0), RT | RS | BIMM},
> +	[insn_cache]	= {M(mm_pool32b_op, 0, 0, mm_cache_func, 0, 0), RT | RS | SIMM},
> +	[insn_cfc1]	= {M(mm_pool32f_op, 0, 0, 0, mm_cfc1_op, mm_32f_73_op), RT | RS},
> +	[insn_cfcmsa]	= {M(mm_pool32s_op, 0, msa_cfc_op, 0, 0, mm_32s_elm_op), RD | RE},
> +	[insn_ctc1]	= {M(mm_pool32f_op, 0, 0, 0, mm_ctc1_op, mm_32f_73_op), RT | RS},
> +	[insn_ctcmsa]	= {M(mm_pool32s_op, 0, msa_ctc_op, 0, 0, mm_32s_elm_op), RD | RE},
> +	[insn_daddu]	= {0, 0},
> +	[insn_daddiu]	= {0, 0},
> +	[insn_di]	= {M(mm_pool32a_op, 0, 0, 0, mm_di_op, mm_pool32axf_op), RS},
> +	[insn_divu]	= {M(mm_pool32a_op, 0, 0, 0, mm_divu_op, mm_pool32axf_op), RT | RS},
> +	[insn_dmfc0]	= {0, 0},
> +	[insn_dmtc0]	= {0, 0},
> +	[insn_dsll]	= {0, 0},
> +	[insn_dsll32]	= {0, 0},
> +	[insn_dsra]	= {0, 0},
> +	[insn_dsrl]	= {0, 0},
> +	[insn_dsrl32]	= {0, 0},
> +	[insn_drotr]	= {0, 0},
> +	[insn_drotr32]	= {0, 0},
> +	[insn_dsubu]	= {0, 0},
> +	[insn_eret]	= {M(mm_pool32a_op, 0, 0, 0, mm_eret_op, mm_pool32axf_op), 0},
> +	[insn_ins]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_ins_op), RT | RS | RD | RE},
> +	[insn_ext]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_ext_op), RT | RS | RD | RE},
> +	[insn_j]	= {M(mm_j32_op, 0, 0, 0, 0, 0), JIMM},
> +	[insn_jal]	= {M(mm_jal32_op, 0, 0, 0, 0, 0), JIMM},
> +	[insn_jalr]	= {M(mm_pool32a_op, 0, 0, 0, mm_jalr_op, mm_pool32axf_op), RT | RS},
> +	[insn_jr]	= {M(mm_pool32a_op, 0, 0, 0, mm_jalr_op, mm_pool32axf_op), RS},
> +	[insn_lb]	= {M(mm_lb32_op, 0, 0, 0, 0, 0), RT | RS | SIMM},
> +	[insn_ld]	= {0, 0},
> +	[insn_lh]	= {M(mm_lh32_op, 0, 0, 0, 0, 0), RS | RS | SIMM},
> +	[insn_ll]	= {M(mm_pool32c_op, 0, 0, (mm_ll_func << 1), 0, 0), RS | RT | SIMM},
> +	[insn_lld]	= {0, 0},
> +	[insn_lui]	= {M(mm_pool32i_op, mm_lui_op, 0, 0, 0, 0), RS | SIMM},
> +	[insn_lw]	= {M(mm_lw32_op, 0, 0, 0, 0, 0), RT | RS | SIMM},
> +	[insn_mfc0]	= {M(mm_pool32a_op, 0, 0, 0, mm_mfc0_op, mm_pool32axf_op), RT | RS | RD},
> +	[insn_mfhi]	= {M(mm_pool32a_op, 0, 0, 0, mm_mfhi32_op, mm_pool32axf_op), RS},
> +	[insn_mflo]	= {M(mm_pool32a_op, 0, 0, 0, mm_mflo32_op, mm_pool32axf_op), RS},
> +	[insn_mtc0]	= {M(mm_pool32a_op, 0, 0, 0, mm_mtc0_op, mm_pool32axf_op), RT | RS | RD},
> +	[insn_mthi]	= {M(mm_pool32a_op, 0, 0, 0, mm_mthi32_op, mm_pool32axf_op), RS},
> +	[insn_mtlo]	= {M(mm_pool32a_op, 0, 0, 0, mm_mtlo32_op, mm_pool32axf_op), RS},
> +	[insn_mul]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_mul_op), RT | RS | RD},
> +	[insn_or]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_or32_op), RT | RS | RD},
> +	[insn_ori]	= {M(mm_ori32_op, 0, 0, 0, 0, 0), RT | RS | UIMM},
> +	[insn_pref]	= {M(mm_pool32c_op, 0, 0, (mm_pref_func << 1), 0, 0), RT | RS | SIMM},
> +	[insn_rfe]	= {0, 0},
> +	[insn_sc]	= {M(mm_pool32c_op, 0, 0, (mm_sc_func << 1), 0, 0), RT | RS | SIMM},
> +	[insn_scd]	= {0, 0},
> +	[insn_sd]	= {0, 0},
> +	[insn_sll]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_sll32_op), RT | RS | RD},
> +	[insn_sllv]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_sllv32_op), RT | RS | RD},
> +	[insn_slt]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_slt_op), RT | RS | RD},
> +	[insn_sltiu]	= {M(mm_sltiu32_op, 0, 0, 0, 0, 0), RT | RS | SIMM},
> +	[insn_sltu]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_sltu_op), RT | RS | RD},
> +	[insn_sra]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_sra_op), RT | RS | RD},
> +	[insn_srl]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_srl32_op), RT | RS | RD},
> +	[insn_srlv]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_srlv32_op), RT | RS | RD},
> +	[insn_rotr]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_rotr_op), RT | RS | RD},
> +	[insn_subu]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_subu32_op), RT | RS | RD},
> +	[insn_sw]	= {M(mm_sw32_op, 0, 0, 0, 0, 0), RT | RS | SIMM},
> +	[insn_sync]	= {M(mm_pool32a_op, 0, 0, 0, mm_sync_op, mm_pool32axf_op), RS},
> +	[insn_tlbp]	= {M(mm_pool32a_op, 0, 0, 0, mm_tlbp_op, mm_pool32axf_op), 0},
> +	[insn_tlbr]	= {M(mm_pool32a_op, 0, 0, 0, mm_tlbr_op, mm_pool32axf_op), 0},
> +	[insn_tlbwi]	= {M(mm_pool32a_op, 0, 0, 0, mm_tlbwi_op, mm_pool32axf_op), 0},
> +	[insn_tlbwr]	= {M(mm_pool32a_op, 0, 0, 0, mm_tlbwr_op, mm_pool32axf_op), 0},
> +	[insn_wait]	= {M(mm_pool32a_op, 0, 0, 0, mm_wait_op, mm_pool32axf_op), SCIMM},
> +	[insn_wsbh]	= {M(mm_pool32a_op, 0, 0, 0, mm_wsbh_op, mm_pool32axf_op), RT | RS},
> +	[insn_xor]	= {M(mm_pool32a_op, 0, 0, 0, 0, mm_xor32_op), RT | RS | RD},
> +	[insn_xori]	= {M(mm_xori32_op, 0, 0, 0, 0, 0), RT | RS | UIMM},
> +	[insn_dins]	= {0, 0},
> +	[insn_dinsm]	= {0, 0},
> +	[insn_syscall]	= {M(mm_pool32a_op, 0, 0, 0, mm_syscall_op, mm_pool32axf_op), SCIMM},
> +	[insn_bbit0]	= {0, 0},
> +	[insn_bbit1]	= {0, 0},
> +	[insn_lwx]	= {0, 0},
> +	[insn_ldx]	= {0, 0},
>   };
>   
>   #undef M
> @@ -156,20 +155,17 @@ static inline u32 build_jimm(u32 arg)
>    */
>   static void build_insn(u32 **buf, enum opcode opc, ...)
>   {
> -	struct insn *ip = NULL;
> -	unsigned int i;
> +	const struct insn *ip;
>   	va_list ap;
>   	u32 op;
>   
> -	for (i = 0; insn_table_MM[i].opcode != insn_invalid; i++)
> -		if (insn_table_MM[i].opcode == opc) {
> -			ip = &insn_table_MM[i];
> -			break;
> -		}
> -
> -	if (!ip || (opc == insn_daddiu && r4k_daddiu_bug()))
> +	if (opc < 0 || opc >= insn_invalid ||
> +	    (opc == insn_daddiu && r4k_daddiu_bug()) ||
> +	    (insn_table_MM[opc].match == 0 && insn_table_MM[opc].fields == 0))
>   		panic("Unsupported Micro-assembler instruction %d", opc);
>   
> +	ip = &insn_table_MM[opc];
> +
>   	op = ip->match;
>   	va_start(ap, opc);
>   	if (ip->fields & RS) {
> diff --git a/arch/mips/mm/uasm-mips.c b/arch/mips/mm/uasm-mips.c
> index 2277499..f3937e3 100644
> --- a/arch/mips/mm/uasm-mips.c
> +++ b/arch/mips/mm/uasm-mips.c
> @@ -48,126 +48,124 @@
>   
>   #include "uasm.c"
>   
> -static struct insn insn_table[] = {
> -	{ insn_addiu, M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
> -	{ insn_addu, M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD },
> -	{ insn_andi, M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM },
> -	{ insn_and, M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD },
> -	{ insn_bbit0, M(lwc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
> -	{ insn_bbit1, M(swc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
> -	{ insn_beql, M(beql_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
> -	{ insn_beq, M(beq_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
> -	{ insn_bgezl, M(bcond_op, 0, bgezl_op, 0, 0, 0), RS | BIMM },
> -	{ insn_bgez, M(bcond_op, 0, bgez_op, 0, 0, 0), RS | BIMM },
> -	{ insn_bltzl, M(bcond_op, 0, bltzl_op, 0, 0, 0), RS | BIMM },
> -	{ insn_bltz, M(bcond_op, 0, bltz_op, 0, 0, 0), RS | BIMM },
> -	{ insn_bne, M(bne_op, 0, 0, 0, 0, 0), RS | RT | BIMM },
> +static const struct insn const insn_table[insn_invalid] = {
> +	[insn_addiu]	= {M(addiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM},
> +	[insn_addu]	= {M(spec_op, 0, 0, 0, 0, addu_op), RS | RT | RD},
> +	[insn_and]	= {M(spec_op, 0, 0, 0, 0, and_op), RS | RT | RD},
> +	[insn_andi]	= {M(andi_op, 0, 0, 0, 0, 0), RS | RT | UIMM},
> +	[insn_bbit0]	= {M(lwc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM},
> +	[insn_bbit1]	= {M(swc2_op, 0, 0, 0, 0, 0), RS | RT | BIMM},
> +	[insn_beq]	= {M(beq_op, 0, 0, 0, 0, 0), RS | RT | BIMM},
> +	[insn_beql]	= {M(beql_op, 0, 0, 0, 0, 0), RS | RT | BIMM},
> +	[insn_bgez]	= {M(bcond_op, 0, bgez_op, 0, 0, 0), RS | BIMM},
> +	[insn_bgezl]	= {M(bcond_op, 0, bgezl_op, 0, 0, 0), RS | BIMM},
> +	[insn_bltz]	= {M(bcond_op, 0, bltz_op, 0, 0, 0), RS | BIMM},
> +	[insn_bltzl]	= {M(bcond_op, 0, bltzl_op, 0, 0, 0), RS | BIMM},
> +	[insn_bne]	= {M(bne_op, 0, 0, 0, 0, 0), RS | RT | BIMM},
>   #ifndef CONFIG_CPU_MIPSR6
> -	{ insn_cache,  M(cache_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> +	[insn_cache]	= {M(cache_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
>   #else
> -	{ insn_cache,  M6(spec3_op, 0, 0, 0, cache6_op),  RS | RT | SIMM9 },
> +	[insn_cache]	= {M6(spec3_op, 0, 0, 0, cache6_op),  RS | RT | SIMM9},
>   #endif
> -	{ insn_cfc1, M(cop1_op, cfc_op, 0, 0, 0, 0), RT | RD },
> -	{ insn_cfcmsa, M(msa_op, 0, msa_cfc_op, 0, 0, msa_elm_op), RD | RE },
> -	{ insn_ctc1, M(cop1_op, ctc_op, 0, 0, 0, 0), RT | RD },
> -	{ insn_ctcmsa, M(msa_op, 0, msa_ctc_op, 0, 0, msa_elm_op), RD | RE },
> -	{ insn_daddiu, M(daddiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
> -	{ insn_daddu, M(spec_op, 0, 0, 0, 0, daddu_op), RS | RT | RD },
> -	{ insn_dinsm, M(spec3_op, 0, 0, 0, 0, dinsm_op), RS | RT | RD | RE },
> -	{ insn_di, M(cop0_op, mfmc0_op, 0, 12, 0, 0), RT },
> -	{ insn_dins, M(spec3_op, 0, 0, 0, 0, dins_op), RS | RT | RD | RE },
> -	{ insn_divu, M(spec_op, 0, 0, 0, 0, divu_op), RS | RT },
> -	{ insn_dmfc0, M(cop0_op, dmfc_op, 0, 0, 0, 0), RT | RD | SET},
> -	{ insn_dmtc0, M(cop0_op, dmtc_op, 0, 0, 0, 0), RT | RD | SET},
> -	{ insn_drotr32, M(spec_op, 1, 0, 0, 0, dsrl32_op), RT | RD | RE },
> -	{ insn_drotr, M(spec_op, 1, 0, 0, 0, dsrl_op), RT | RD | RE },
> -	{ insn_dsll32, M(spec_op, 0, 0, 0, 0, dsll32_op), RT | RD | RE },
> -	{ insn_dsll, M(spec_op, 0, 0, 0, 0, dsll_op), RT | RD | RE },
> -	{ insn_dsra, M(spec_op, 0, 0, 0, 0, dsra_op), RT | RD | RE },
> -	{ insn_dsrl32, M(spec_op, 0, 0, 0, 0, dsrl32_op), RT | RD | RE },
> -	{ insn_dsrl, M(spec_op, 0, 0, 0, 0, dsrl_op), RT | RD | RE },
> -	{ insn_dsubu, M(spec_op, 0, 0, 0, 0, dsubu_op), RS | RT | RD },
> -	{ insn_eret,  M(cop0_op, cop_op, 0, 0, 0, eret_op),  0 },
> -	{ insn_ext, M(spec3_op, 0, 0, 0, 0, ext_op), RS | RT | RD | RE },
> -	{ insn_ins, M(spec3_op, 0, 0, 0, 0, ins_op), RS | RT | RD | RE },
> -	{ insn_j,  M(j_op, 0, 0, 0, 0, 0),  JIMM },
> -	{ insn_jal,  M(jal_op, 0, 0, 0, 0, 0),	JIMM },
> -	{ insn_jalr,  M(spec_op, 0, 0, 0, 0, jalr_op), RS | RD },
> -	{ insn_j,  M(j_op, 0, 0, 0, 0, 0),  JIMM },
> +	[insn_cfc1]	= {M(cop1_op, cfc_op, 0, 0, 0, 0), RT | RD},
> +	[insn_cfcmsa]	= {M(msa_op, 0, msa_cfc_op, 0, 0, msa_elm_op), RD | RE},
> +	[insn_ctc1]	= {M(cop1_op, ctc_op, 0, 0, 0, 0), RT | RD},
> +	[insn_ctcmsa]	= {M(msa_op, 0, msa_ctc_op, 0, 0, msa_elm_op), RD | RE},
> +	[insn_daddiu]	= {M(daddiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM},
> +	[insn_daddu]	= {M(spec_op, 0, 0, 0, 0, daddu_op), RS | RT | RD},
> +	[insn_di]	= {M(cop0_op, mfmc0_op, 0, 12, 0, 0), RT},
> +	[insn_dins]	= {M(spec3_op, 0, 0, 0, 0, dins_op), RS | RT | RD | RE},
> +	[insn_dinsm]	= {M(spec3_op, 0, 0, 0, 0, dinsm_op), RS | RT | RD | RE},
> +	[insn_divu]	= {M(spec_op, 0, 0, 0, 0, divu_op), RS | RT},
> +	[insn_dmfc0]	= {M(cop0_op, dmfc_op, 0, 0, 0, 0), RT | RD | SET},
> +	[insn_dmtc0]	= {M(cop0_op, dmtc_op, 0, 0, 0, 0), RT | RD | SET},
> +	[insn_drotr]	= {M(spec_op, 1, 0, 0, 0, dsrl_op), RT | RD | RE},
> +	[insn_drotr32]	= {M(spec_op, 1, 0, 0, 0, dsrl32_op), RT | RD | RE},
> +	[insn_dsll]	= {M(spec_op, 0, 0, 0, 0, dsll_op), RT | RD | RE},
> +	[insn_dsll32]	= {M(spec_op, 0, 0, 0, 0, dsll32_op), RT | RD | RE},
> +	[insn_dsra]	= {M(spec_op, 0, 0, 0, 0, dsra_op), RT | RD | RE},
> +	[insn_dsrl]	= {M(spec_op, 0, 0, 0, 0, dsrl_op), RT | RD | RE},
> +	[insn_dsrl32]	= {M(spec_op, 0, 0, 0, 0, dsrl32_op), RT | RD | RE},
> +	[insn_dsubu]	= {M(spec_op, 0, 0, 0, 0, dsubu_op), RS | RT | RD},
> +	[insn_eret]	= {M(cop0_op, cop_op, 0, 0, 0, eret_op),  0},
> +	[insn_ext]	= {M(spec3_op, 0, 0, 0, 0, ext_op), RS | RT | RD | RE},
> +	[insn_ins]	= {M(spec3_op, 0, 0, 0, 0, ins_op), RS | RT | RD | RE},
> +	[insn_j]	= {M(j_op, 0, 0, 0, 0, 0),  JIMM},
> +	[insn_jal]	= {M(jal_op, 0, 0, 0, 0, 0),	JIMM},
> +	[insn_jalr]	= {M(spec_op, 0, 0, 0, 0, jalr_op), RS | RD},
>   #ifndef CONFIG_CPU_MIPSR6
> -	{ insn_jr,  M(spec_op, 0, 0, 0, 0, jr_op),  RS },
> +	[insn_jr]	= {M(spec_op, 0, 0, 0, 0, jr_op),  RS},
>   #else
> -	{ insn_jr,  M(spec_op, 0, 0, 0, 0, jalr_op),  RS },
> +	[insn_jr]	= {M(spec_op, 0, 0, 0, 0, jalr_op),  RS},
>   #endif
> -	{ insn_lb, M(lb_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
> -	{ insn_ld,  M(ld_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> -	{ insn_ldx, M(spec3_op, 0, 0, 0, ldx_op, lx_op), RS | RT | RD },
> -	{ insn_lh,  M(lh_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> -	{ insn_lhu,  M(lhu_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> +	[insn_lb]	= {M(lb_op, 0, 0, 0, 0, 0), RS | RT | SIMM},
> +	[insn_ld]	= {M(ld_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
> +	[insn_lddir]	= {M(lwc2_op, 0, 0, 0, lddir_op, mult_op), RS | RT | RD},
> +	[insn_ldpte]	= {M(lwc2_op, 0, 0, 0, ldpte_op, mult_op), RS | RD},
> +	[insn_ldx]	= {M(spec3_op, 0, 0, 0, ldx_op, lx_op), RS | RT | RD},
> +	[insn_lh]	= {M(lh_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
> +	[insn_lhu]	= {M(lhu_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
>   #ifndef CONFIG_CPU_MIPSR6
> -	{ insn_lld,  M(lld_op, 0, 0, 0, 0, 0),	RS | RT | SIMM },
> -	{ insn_ll,  M(ll_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> +	[insn_ll]	= {M(ll_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
> +	[insn_lld]	= {M(lld_op, 0, 0, 0, 0, 0),	RS | RT | SIMM},
>   #else
> -	{ insn_lld,  M6(spec3_op, 0, 0, 0, lld6_op),  RS | RT | SIMM9 },
> -	{ insn_ll,  M6(spec3_op, 0, 0, 0, ll6_op),  RS | RT | SIMM9 },
> +	[insn_ll]	= {M6(spec3_op, 0, 0, 0, ll6_op),  RS | RT | SIMM9},
> +	[insn_lld]	= {M6(spec3_op, 0, 0, 0, lld6_op),  RS | RT | SIMM9},
>   #endif
> -	{ insn_lui,  M(lui_op, 0, 0, 0, 0, 0),	RT | SIMM },
> -	{ insn_lw,  M(lw_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> -	{ insn_lwx, M(spec3_op, 0, 0, 0, lwx_op, lx_op), RS | RT | RD },
> -	{ insn_mfc0,  M(cop0_op, mfc_op, 0, 0, 0, 0),  RT | RD | SET},
> -	{ insn_mfhc0,  M(cop0_op, mfhc0_op, 0, 0, 0, 0),  RT | RD | SET},
> -	{ insn_mfhi,  M(spec_op, 0, 0, 0, 0, mfhi_op), RD },
> -	{ insn_mflo,  M(spec_op, 0, 0, 0, 0, mflo_op), RD },
> -	{ insn_mtc0,  M(cop0_op, mtc_op, 0, 0, 0, 0),  RT | RD | SET},
> -	{ insn_mthc0,  M(cop0_op, mthc0_op, 0, 0, 0, 0),  RT | RD | SET},
> -	{ insn_mthi,  M(spec_op, 0, 0, 0, 0, mthi_op), RS },
> -	{ insn_mtlo,  M(spec_op, 0, 0, 0, 0, mtlo_op), RS },
> +	[insn_lui]	= {M(lui_op, 0, 0, 0, 0, 0),	RT | SIMM},
> +	[insn_lw]	= {M(lw_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
> +	[insn_lwx]	= {M(spec3_op, 0, 0, 0, lwx_op, lx_op), RS | RT | RD},
> +	[insn_mfc0]	= {M(cop0_op, mfc_op, 0, 0, 0, 0),  RT | RD | SET},
> +	[insn_mfhc0]	= {M(cop0_op, mfhc0_op, 0, 0, 0, 0),  RT | RD | SET},
> +	[insn_mfhi]	= {M(spec_op, 0, 0, 0, 0, mfhi_op), RD},
> +	[insn_mflo]	= {M(spec_op, 0, 0, 0, 0, mflo_op), RD},
> +	[insn_mtc0]	= {M(cop0_op, mtc_op, 0, 0, 0, 0),  RT | RD | SET},
> +	[insn_mthc0]	= {M(cop0_op, mthc0_op, 0, 0, 0, 0),  RT | RD | SET},
> +	[insn_mthi]	= {M(spec_op, 0, 0, 0, 0, mthi_op), RS},
> +	[insn_mtlo]	= {M(spec_op, 0, 0, 0, 0, mtlo_op), RS},
>   #ifndef CONFIG_CPU_MIPSR6
> -	{ insn_mul, M(spec2_op, 0, 0, 0, 0, mul_op), RS | RT | RD},
> +	[insn_mul]	= {M(spec2_op, 0, 0, 0, 0, mul_op), RS | RT | RD},
>   #else
> -	{ insn_mul, M(spec_op, 0, 0, 0, mult_mul_op, mult_op), RS | RT | RD},
> +	[insn_mul]	= {M(spec_op, 0, 0, 0, mult_mul_op, mult_op), RS | RT | RD},
>   #endif
> -	{ insn_ori,  M(ori_op, 0, 0, 0, 0, 0),	RS | RT | UIMM },
> -	{ insn_or,  M(spec_op, 0, 0, 0, 0, or_op),  RS | RT | RD },
> +	[insn_or]	= {M(spec_op, 0, 0, 0, 0, or_op),  RS | RT | RD},
> +	[insn_ori]	= {M(ori_op, 0, 0, 0, 0, 0),	RS | RT | UIMM},
>   #ifndef CONFIG_CPU_MIPSR6
> -	{ insn_pref,  M(pref_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> +	[insn_pref]	= {M(pref_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
>   #else
> -	{ insn_pref,  M6(spec3_op, 0, 0, 0, pref6_op),  RS | RT | SIMM9 },
> +	[insn_pref]	= {M6(spec3_op, 0, 0, 0, pref6_op),  RS | RT | SIMM9},
>   #endif
> -	{ insn_rfe,  M(cop0_op, cop_op, 0, 0, 0, rfe_op),  0 },
> -	{ insn_rotr,  M(spec_op, 1, 0, 0, 0, srl_op),  RT | RD | RE },
> +	[insn_rfe]	= {M(cop0_op, cop_op, 0, 0, 0, rfe_op),  0},
> +	[insn_rotr]	= {M(spec_op, 1, 0, 0, 0, srl_op),  RT | RD | RE},
>   #ifndef CONFIG_CPU_MIPSR6
> -	{ insn_scd,  M(scd_op, 0, 0, 0, 0, 0),	RS | RT | SIMM },
> -	{ insn_sc,  M(sc_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> +	[insn_sc]	= {M(sc_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
> +	[insn_scd]	= {M(scd_op, 0, 0, 0, 0, 0),	RS | RT | SIMM},
>   #else
> -	{ insn_scd,  M6(spec3_op, 0, 0, 0, scd6_op),  RS | RT | SIMM9 },
> -	{ insn_sc,  M6(spec3_op, 0, 0, 0, sc6_op),  RS | RT | SIMM9 },
> +	[insn_sc]	= {M6(spec3_op, 0, 0, 0, sc6_op),  RS | RT | SIMM9},
> +	[insn_scd]	= {M6(spec3_op, 0, 0, 0, scd6_op),  RS | RT | SIMM9},
>   #endif
> -	{ insn_sd,  M(sd_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> -	{ insn_sll,  M(spec_op, 0, 0, 0, 0, sll_op),  RT | RD | RE },
> -	{ insn_sllv,  M(spec_op, 0, 0, 0, 0, sllv_op),  RS | RT | RD },
> -	{ insn_slt,  M(spec_op, 0, 0, 0, 0, slt_op),  RS | RT | RD },
> -	{ insn_sltiu, M(sltiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM },
> -	{ insn_sltu, M(spec_op, 0, 0, 0, 0, sltu_op), RS | RT | RD },
> -	{ insn_sra,  M(spec_op, 0, 0, 0, 0, sra_op),  RT | RD | RE },
> -	{ insn_srl,  M(spec_op, 0, 0, 0, 0, srl_op),  RT | RD | RE },
> -	{ insn_srlv,  M(spec_op, 0, 0, 0, 0, srlv_op),  RS | RT | RD },
> -	{ insn_subu,  M(spec_op, 0, 0, 0, 0, subu_op),	RS | RT | RD },
> -	{ insn_sw,  M(sw_op, 0, 0, 0, 0, 0),  RS | RT | SIMM },
> -	{ insn_sync, M(spec_op, 0, 0, 0, 0, sync_op), RE },
> -	{ insn_syscall, M(spec_op, 0, 0, 0, 0, syscall_op), SCIMM},
> -	{ insn_tlbp,  M(cop0_op, cop_op, 0, 0, 0, tlbp_op),  0 },
> -	{ insn_tlbr,  M(cop0_op, cop_op, 0, 0, 0, tlbr_op),  0 },
> -	{ insn_tlbwi,  M(cop0_op, cop_op, 0, 0, 0, tlbwi_op),  0 },
> -	{ insn_tlbwr,  M(cop0_op, cop_op, 0, 0, 0, tlbwr_op),  0 },
> -	{ insn_wait, M(cop0_op, cop_op, 0, 0, 0, wait_op), SCIMM },
> -	{ insn_wsbh, M(spec3_op, 0, 0, 0, wsbh_op, bshfl_op), RT | RD },
> -	{ insn_xori,  M(xori_op, 0, 0, 0, 0, 0),  RS | RT | UIMM },
> -	{ insn_xor,  M(spec_op, 0, 0, 0, 0, xor_op),  RS | RT | RD },
> -	{ insn_yield, M(spec3_op, 0, 0, 0, 0, yield_op), RS | RD },
> -	{ insn_ldpte, M(lwc2_op, 0, 0, 0, ldpte_op, mult_op), RS | RD },
> -	{ insn_lddir, M(lwc2_op, 0, 0, 0, lddir_op, mult_op), RS | RT | RD },
> -	{ insn_invalid, 0, 0 }
> +	[insn_sd]	= {M(sd_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
> +	[insn_sll]	= {M(spec_op, 0, 0, 0, 0, sll_op),  RT | RD | RE},
> +	[insn_sllv]	= {M(spec_op, 0, 0, 0, 0, sllv_op),  RS | RT | RD},
> +	[insn_slt]	= {M(spec_op, 0, 0, 0, 0, slt_op),  RS | RT | RD},
> +	[insn_sltiu]	= {M(sltiu_op, 0, 0, 0, 0, 0), RS | RT | SIMM},
> +	[insn_sltu]	= {M(spec_op, 0, 0, 0, 0, sltu_op), RS | RT | RD},
> +	[insn_sra]	= {M(spec_op, 0, 0, 0, 0, sra_op),  RT | RD | RE},
> +	[insn_srl]	= {M(spec_op, 0, 0, 0, 0, srl_op),  RT | RD | RE},
> +	[insn_srlv]	= {M(spec_op, 0, 0, 0, 0, srlv_op),  RS | RT | RD},
> +	[insn_subu]	= {M(spec_op, 0, 0, 0, 0, subu_op),	RS | RT | RD},
> +	[insn_sw]	= {M(sw_op, 0, 0, 0, 0, 0),  RS | RT | SIMM},
> +	[insn_sync]	= {M(spec_op, 0, 0, 0, 0, sync_op), RE},
> +	[insn_syscall]	= {M(spec_op, 0, 0, 0, 0, syscall_op), SCIMM},
> +	[insn_tlbp]	= {M(cop0_op, cop_op, 0, 0, 0, tlbp_op),  0},
> +	[insn_tlbr]	= {M(cop0_op, cop_op, 0, 0, 0, tlbr_op),  0},
> +	[insn_tlbwi]	= {M(cop0_op, cop_op, 0, 0, 0, tlbwi_op),  0},
> +	[insn_tlbwr]	= {M(cop0_op, cop_op, 0, 0, 0, tlbwr_op),  0},
> +	[insn_wait]	= {M(cop0_op, cop_op, 0, 0, 0, wait_op), SCIMM},
> +	[insn_wsbh]	= {M(spec3_op, 0, 0, 0, wsbh_op, bshfl_op), RT | RD},
> +	[insn_xor]	= {M(spec_op, 0, 0, 0, 0, xor_op),  RS | RT | RD},
> +	[insn_xori]	= {M(xori_op, 0, 0, 0, 0, 0),  RS | RT | UIMM},
> +	[insn_yield]	= {M(spec3_op, 0, 0, 0, 0, yield_op), RS | RD},
>   };
>   
>   #undef M
> @@ -196,20 +194,17 @@ static inline u32 build_jimm(u32 arg)
>    */
>   static void build_insn(u32 **buf, enum opcode opc, ...)
>   {
> -	struct insn *ip = NULL;
> -	unsigned int i;
> +	const struct insn *ip;
>   	va_list ap;
>   	u32 op;
>   
> -	for (i = 0; insn_table[i].opcode != insn_invalid; i++)
> -		if (insn_table[i].opcode == opc) {
> -			ip = &insn_table[i];
> -			break;
> -		}
> -
> -	if (!ip || (opc == insn_daddiu && r4k_daddiu_bug()))
> +	if (opc < 0 || opc >= insn_invalid ||
> +	    (opc == insn_daddiu && r4k_daddiu_bug()) ||
> +	    (insn_table[opc].match == 0 && insn_table[opc].fields == 0))
>   		panic("Unsupported Micro-assembler instruction %d", opc);
>   
> +	ip = &insn_table[opc];
> +
>   	op = ip->match;
>   	va_start(ap, opc);
>   	if (ip->fields & RS)
> diff --git a/arch/mips/mm/uasm.c b/arch/mips/mm/uasm.c
> index 730363b..f23ed85 100644
> --- a/arch/mips/mm/uasm.c
> +++ b/arch/mips/mm/uasm.c
> @@ -46,7 +46,6 @@ enum fields {
>   #define SIMM9_MASK	0x1ff
>   
>   enum opcode {
> -	insn_invalid,
>   	insn_addiu, insn_addu, insn_and, insn_andi, insn_bbit0, insn_bbit1,
>   	insn_beq, insn_beql, insn_bgez, insn_bgezl, insn_bltz, insn_bltzl,
>   	insn_bne, insn_cache, insn_cfc1, insn_cfcmsa, insn_ctc1, insn_ctcmsa,
> @@ -62,10 +61,10 @@ enum opcode {
>   	insn_srlv, insn_subu, insn_sw, insn_sync, insn_syscall, insn_tlbp,
>   	insn_tlbr, insn_tlbwi, insn_tlbwr, insn_wait, insn_wsbh, insn_xor,
>   	insn_xori, insn_yield, insn_lddir, insn_ldpte, insn_lhu,
> +	insn_invalid /* insn_invalid must be last */
>   };
>   
>   struct insn {
> -	enum opcode opcode;
>   	u32 match;
>   	enum fields fields;
>   };

^ permalink raw reply

* Re: Deleting a dynamic mac entry..
From: Toshiaki Makita @ 2017-05-26  8:15 UTC (permalink / raw)
  To: Manohar Kumar; +Cc: netdev, bridge
In-Reply-To: <CA+N+6-wErt=9XX6u8tPnLbb2DrLqADOnCBn3mDe=qvxCoLCFyg@mail.gmail.com>

On 2017/05/26 14:08, Manohar Kumar wrote:
> On Wed, May 24, 2017 at 6:11 PM, Toshiaki Makita
> <makita.toshiaki@lab.ntt.co.jp> wrote:
>> On 2017/05/25 3:05, Manohar Kumar wrote:
>>> Thanks, Toshiaki.
>>>
>>> What is the right way to set the default_pvid using the bridge command
>>> ? I tried this, which fails..
>>>
>>> root@net-3:~# ip link set dev vxlan0 name untagged type vlan id 0
>>> RTNETLINK answers: Operation not supported
>>> root@net-3:~#
>>>
>>> All the interfaces in the bridge are untagged.
>>
>> # ip link set br0 down
>> # echo 0 > /sys/class/net/br0/bridge/default_pvid
>>
> 
> I have the bridge inside a network namespace. There is no
> /sys/class/net entry for the bridge interface inside the namespace.
> 
> I see online references to this concept of 'tagged' sysfs directories
> to support namespaces. But its not clear how to access the sysfs
> entries for a particular namespace.

Did you remount /sys after entering netns?
If not, remount /sys or use "ip netns" which automatically do it.

> Is there any other way to set the default_pvid for the bridge
> interface inside namespace ?

No, as of 3.19.


Toshiaki Makita

^ permalink raw reply

* Re: [PATCH net-next v2 0/6] nfp: devlink port implementation
From: Jiri Pirko @ 2017-05-26  8:25 UTC (permalink / raw)
  To: Jakub Kicinski; +Cc: netdev, oss-drivers
In-Reply-To: <20170526080336.32689-1-jakub.kicinski@netronome.com>

Fri, May 26, 2017 at 10:03:30AM CEST, jakub.kicinski@netronome.com wrote:
>Hi!
>
>This series adds basic devlink support.  The operations we can perform
>are port show and port split/unsplit.
>
>v2:
>Register devlink first, and then register all the ports.  Port {,un}split
>searches the port list, which is protected by a mutex.  If port split
>is requested before ports are registered we will simply not find the port
>and return -EINVAL.

Looks fine to me now. Thanks!


>
>Jakub Kicinski (5):
>  nfp: move mutex init out of net code
>  nfp: add helper for cleaning up vNICs
>  nfp: register ports as devlink ports
>  nfp: calculate total port lanes for split
>  nfp: support port splitting via devlink
>
>Simon Horman (1):
>  nfp: add devlink support
>
> drivers/net/ethernet/netronome/nfp/Makefile        |   1 +
> drivers/net/ethernet/netronome/nfp/nfp_devlink.c   | 181 +++++++++++++++++++++
> drivers/net/ethernet/netronome/nfp/nfp_main.c      |  28 +++-
> drivers/net/ethernet/netronome/nfp/nfp_main.h      |   3 +
> drivers/net/ethernet/netronome/nfp/nfp_net_main.c  |  61 ++++---
> drivers/net/ethernet/netronome/nfp/nfp_port.c      |  19 +++
> drivers/net/ethernet/netronome/nfp/nfp_port.h      |  12 ++
> .../net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h   |   3 +
> .../ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c   |  11 +-
> 9 files changed, 289 insertions(+), 30 deletions(-)
> create mode 100644 drivers/net/ethernet/netronome/nfp/nfp_devlink.c
>
>-- 
>2.11.0
>

^ permalink raw reply

* Re: [for-next 4/6] net/mlx5: FPGA, Add basic support for Innova
From: Saeed Mahameed @ 2017-05-26  8:29 UTC (permalink / raw)
  To: Jes Sorensen
  Cc: Ilan Tayari, Alexei Starovoitov, Saeed Mahameed, David S. Miller,
	Doug Ledford, netdev@vger.kernel.org, linux-rdma@vger.kernel.org
In-Reply-To: <00716e5a-8b51-0b3f-a1b8-1bb7b346a66a@fb.com>

On Thu, May 25, 2017 at 11:48 PM, Jes Sorensen <jsorensen@fb.com> wrote:
> On 05/25/2017 06:40 AM, Saeed Mahameed wrote:
>>
>> On Thu, May 25, 2017 at 8:20 AM, Ilan Tayari <ilant@mellanox.com> wrote:
>>>>
>>>> -----Original Message-----
>>>> Can you put it into different driver? Dumping everything into by far
>>>> the biggest nic driver already is already huge headache in terms on
>>>> maintainability, debugging and back ports.
>>>> Look at how intel splits their drivers.
>>>> ixgb, ixgbe, ixgbevf are different drivers thought they have a lot in
>>>> common. On one side it's a bit of copy paste, but on the other side
>>
>>
>> I don't think the ixgb example is the same, simply  ixgb, ixgbe,
>> ixgbevf have different PCI IDs
>> and even different SW/FW interfaces. On the other hand, same mlx5
>> driver can support all of
>> ConnetX4/5/6 device IDs with the same code flows, same interfaces.
>>
>>>> it makes drivers much easier to develop and maintain independently.
>>>> ConnectX-6 code and any future hw support doesn't belong to
>>>> mlx5 driver at all.
>>
>>
>> Sorry i must disagree with you on this for the same reasons Ilan
>> mentioned.
>> We can perfectly achieve the same with modular driver design all under the
>> same .ko module, with some kconfig flags to reduce the amount of
>> code/features
>> this .ko provides.
>
>
> If I get this right, the FPGA is independent and could in theory be used for
> non network stuff. It really should have it's own driver in that case, and
> you should provide accessor functionality via the mlx5 driver.
>

Hi Jes,

No, It is clearly stated in the commit message :

"The FPGA is a bump-on-the-wire and thus affects operation of
the mlx5_core driver on the ConnectX ASIC."

Which means mlx5 FPGA user can only write logic which affects only
packets going in/out
A ConnectX chip - so it is only network stuff -.

> We have this with other devices in the kernel where a primary device driver
> provides an interface for an additional sub-driver to access another device
> behind it. Like bt-coexist in some of the wifi drivers allowing access to a
> bluetooth device behind it.
>

Blutooth over wifi or vise versa is a very good example to what you
are requesting.
But, it doesn't fit to what we are trying to do here. mlx5 FGPA is a
ConnectX card feature, not a new protocol.

> Jes

^ permalink raw reply

* Re: [patch net-next 01/18] bridge: Export VLAN filtering state
From: Nikolay Aleksandrov @ 2017-05-26  8:55 UTC (permalink / raw)
  To: Jiri Pirko, netdev; +Cc: davem, idosch, mlxsw, stephen
In-Reply-To: <20170526063740.8909-2-jiri@resnulli.us>

On 5/26/17 9:37 AM, Jiri Pirko wrote:
> From: Ido Schimmel <idosch@mellanox.com>
> 
> It's useful for drivers supporting bridge offload to be able to query
> the bridge's VLAN filtering state.
> 
> Currently, upon enslavement to a bridge master, the offloading driver
> will only learn about the bridge's VLAN filtering state after the bridge
> device was already linked with its slave.
> 
> Being able to query the bridge's VLAN filtering state allows such
> drivers to forbid enslavement in case resource couldn't be allocated for
> a VLAN-aware bridge and also choose the correct initialization routine
> for the enslaved port, which is dependent on the bridge type.
> 
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> ---
>   include/linux/if_bridge.h | 9 +++++++++
>   net/bridge/br_if.c        | 2 +-
>   net/bridge/br_mdb.c       | 4 ++--
>   net/bridge/br_netlink.c   | 2 +-
>   net/bridge/br_private.h   | 9 ---------
>   net/bridge/br_vlan.c      | 8 ++++++++
>   6 files changed, 21 insertions(+), 13 deletions(-)
> 

I must say this bridge -> dev -> bridge looks weird from the bridge POV.
Since exports like this seem to be increasing I think it'd be nice to
make some API that can be queried instead of exporting symbols for each
bridge option or attribute. In this case maybe a simpler solution would've
been only a new exported symbol for external users.

The patch itself looks good to me.

Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

^ permalink raw reply

* Re: [patch net-next 02/18] bridge: Export multicast enabled state
From: Nikolay Aleksandrov @ 2017-05-26  8:56 UTC (permalink / raw)
  To: Jiri Pirko, netdev; +Cc: davem, idosch, mlxsw, stephen
In-Reply-To: <20170526063740.8909-3-jiri@resnulli.us>

On 5/26/17 9:37 AM, Jiri Pirko wrote:
> From: Ido Schimmel <idosch@mellanox.com>
> 
> During enslavement to a bridge, after the CHANGEUPPER is sent, the
> multicast enabled state of the bridge isn't propagated down to the
> offloading driver unless it's changed.
> 
> This patch allows such drivers to query the multicast enabled state from
> the bridge, so that they'll be able to correctly configure their flood
> tables during port enslavement.
> 
> In case multicast is disabled, unregistered multicast packets can be
> treated as broadcast and be flooded through all the bridge ports.
> 
> Signed-off-by: Ido Schimmel <idosch@mellanox.com>
> Signed-off-by: Jiri Pirko <jiri@mellanox.com>
> ---
>   include/linux/if_bridge.h | 5 +++++
>   net/bridge/br_multicast.c | 8 ++++++++
>   2 files changed, 13 insertions(+)
> 

Reviewed-by: Nikolay Aleksandrov <nikolay@cumulusnetworks.com>

^ permalink raw reply

* Re: [for-next 4/6] net/mlx5: FPGA, Add basic support for Innova
From: Saeed Mahameed @ 2017-05-26  8:59 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: Ilan Tayari, Saeed Mahameed, David S. Miller, Doug Ledford,
	netdev@vger.kernel.org, linux-rdma@vger.kernel.org,
	jsorensen@fb.com
In-Reply-To: <20170526030701.du4345mbprhcwjyi@ast-mbp>

On Fri, May 26, 2017 at 6:07 AM, Alexei Starovoitov
<alexei.starovoitov@gmail.com> wrote:
> On Thu, May 25, 2017 at 05:20:04AM +0000, Ilan Tayari wrote:
>>
>> If you do want this, then splitting some of the logic to a
>> separate kernel object will not gain anything useful (logic would stay
>> the same), and just pollute the exported symbol table and open up the door
>> for issues of inter-module compatibility and so on.
>
> in other words instead of properly designing inter-module api
> you just want to add everything into one giant 'driver'
> because it's easier to do so. Understandable, but it leads
> to unmaintainable device infrastructure long term.
>

What is wrong with giant 'driver'  ? :-)
BTW making the fpga a separate module is as easy as adding one line to
the make file
and moving the entry points functions (fpga_init/cleanup) form mlx5
init flow into a "mlx5_interface" instance and register it with the
mlx5_core.

But again i don't see a point of doing so, the code will still look
the same and sit in the same places.

so one giant ko file or small separate modules is basically the same,
from my point of view. modular design have nothing to do with the
compilation output binary, it should be considered regardless of the
compiler output.

Which we tried to not far a go to break the driver into sub-module
directories, each with its own responsibility, but it was too late for
that.

And for FPGA support, we did it correctly this time, all the new code
is under mlx5/core/fgpa ..
if you don't like core/fpga, ok just simply "CONFIG_MLX5_FPGA = no"
and all of that code/directory will disappear from your ko file and
will not be touched in compilation time, and the core code will still
look the same.

>> Furthermore, the next patchset will introduce IPSec offload capabilities
>> Which are declared in netdev->hw_features. Those cannot be modified
>> after the netdevice is created, so all the extra logic has to be
>> integrated into the mlx5 ethernet driver. This is another reason why
>> a separate driver is a bad idea.
>
> that increases my concerns even more.
> ipsec offload is a new feature for new hw, yet you're trying to
> hide it in the mlx5 'driver'.
>

Well, this is a well known dilemma, if one has a new feature and has no sandbox
area to put it in the first phase, it is better to start from the most
common place
for that feature which is the originating place, before defining
APIs/infrastructures,
until the feature is complete and every body is happy about it.

Same was done for GRO, XDP , you name it ..

nothing is being hidden here, we are adding new HW offloads, not that
different from
csum offloads, which no one can live without these days, and i believe
in few years IPSec and TLS and security offloads will be no less
important than csum offloads.

Someone has to start somewhere and we choose to start in our driver,
if you have a better IPSec generic interface that allows modular
module separation we are happy to hear about it.

> mlx5 already supports cx4/cx4-lx/cx5 and not even released cx6.

I will take this as a complement ;-), please see more info below.

> All of them have different feature sets.

Not different feature sets, but i expect some changes through out the
evolution of the ConnectX chip , and those changes can be:
1. internal bug fixes/internal improvements.
2. new extra features from the previous generation.

But the chip is the same chip, i.e same driver works on all of the
chips with the basic/standard feature set.

> The only common piece is driver/fw cmd interface and _some_ aspects
> of rx/tx descriptors. Everything else is different.

I can add more to the list.
basic offloads, steering management, eswitch, HW objects and semantics
QPs/RQs/SQs/CQs/EQs and their manipulation semantics, internal page
memory management, NIC initialization and teardown flows  are the same
and many more.


> cx4-lx doesn't have infiniband and rdma, yet there is a ton of code

although it doesn't have infinband support, cx4-lx have rdma support,
you can perfectly load mlx5_ib and work with RDMA over ethernet
(RoCE).
which is 99% of the mlx5_ib&mlx5_core code. (really !)
so the ton of code is still valid for cx4-lx.

> in the driver that deals with it.
> cx5 has fancy storage interfaces for nvme, etc I don't think they
> are part of the mlx5 'driver' yet. Are you going to dump them
> in there as well?
> Take a look at the simplest feature-wise cx4-lx. It has
> eswitch which is full l2 switch with mac table, drop policy,
> counters and such. Yet kernel knows nothing about it.
> Everything is hidden in mlx5 'driver' with its own special
> interfaces to manage it.

1. eswitch is a very integral steering feature of the ConnectX family
and is valid for all ConnectX4/lx/5/6 .. cards.
2. kenrel doesn't and can't know about it since in the early days of
SRIOV implementation (what the cool kids of switchdev mode call the
legacy sriov mode) is the responsibility of the device driver and it
is an internal arch of the HCA. so it is not our fault it is hidden in
mlx5, we just went with the flow..
3. I agree with you, device driver should be as transparent as
possible to the kernel, and should provide as much info as needed to
the stack.
4. switchdev mode came to solve this exact issue, and the kernel stack
even up to user space are perfectly aware of the nic eswitch
capabilities.

being said, even if the kernel is aware or not aware of the eswitch it
doesn't mean it should or shouldn't sit in the same mlx5 ko file.

> Now you want to hide fpga with custom logic behind mlx5 'driver'
> and manage it through mlx5 interfaces?
> That's not acceptable.
> mlx fpga got to have generic kernel representation that intel
> and other fpga vendors can use.
>

quoting Ilan from his commit message:

"The FPGA is a bump-on-the-wire and thus affects operation of
the mlx5_core driver on the ConnectX ASIC."

This is not a general purpose FPGA ! it even doesn't have a PCI Id or
it is own PCI function.
it simply allows the ConnectX Chip user to inspect/inject or run user
specif login on traffic going in/out of the chip.

But i agree with you some serious API brainstorming should be
considered, but not at this stage,
this patch only tells the ConnectX card (if you have FPGA, please enable it).

> mlx5 driver has to be modularized and since it's not too late
> cx6 support has to be removed from it.
>

I agree with you on the first part, Yes i would like to better
modularize the driver, i will even consider taking it to the extreme
and have separate module for each sub mlx5 module
e.g:

mlx5_core.ko
mlx5_eswitch.ko
mlx5_vxaln.ko
mlx5_vf_repreentor.ko
mlx5_ipoib.ko
...
even mlx5_xdp.ko ( not really ;-) )

If this what it takes to more logically and modularly break mlx5/core
into hierarchical design,
Please count me in. And i would like to hear Dave explicitly say i am
ok with this first.

But, re cx6 I am not sure i can agree on this for the simple fact:

it took 3 years to get mlx5 (Cx4/lx) driver to provide similar feature
set as mlx4 (Cx3).
and it literally took 0 lines of codes 1 day of regression to test
mlx5 driver over CX5 !
Now All we need is to add the new features of CX5 on top of the
already existing driver and i will be more than happy to hear about
exciting Ideas on how to modularly do that in the same driver,
and provide clear separation (beleive me it is is to do, if i am
allowed to split the driver into directories) but i can't do it in a
completely separate driver with a base code library, it is simply
wrong and non scalable (even if someone is not careful enough it could
make a lot of dependency mess between mlx5 modules)

> Thankfully only few cx6 pci ids were added to mlx5, but driver
> knows nothing about cx6 features, so we can properly design it.
>

> Since driver/fw interface is common between cx4+ this part
> can be moved into mlx_core.ko or done as library
> the way chelsio did it in libcxgb.
>

driver/fw interfaces are not the only common part, it is all basic
standard netdev/rdma and linux networkinng stuff are the same.

-Saeed.

^ permalink raw reply

* Re: [ISSUE: sky2 - rx error] Link stops working under heavy traffic load connected to a mv88e6176
From: Rafa Corvillo @ 2017-05-26 10:13 UTC (permalink / raw)
  To: Andrew Lunn; +Cc: Stephen Hemminger, netdev
In-Reply-To: <591B267D.1030800@aoifes.com>

As modifying sky2 code I have not could get any solution, then I have 
modified some parameters on the ethernet interface and using a MTU = 
1503 and disabling TSO (TCP Segmentation Offload) mechanism all 
communication errors disappear, both the rx errors due to too long 
packets and tx timeout errors. I have performed iperf tests during 1 
hour (downstream and upstream) and the performance of the ethernet is 
stable. Furthermore, disabling SG (scatter-gather) improves the 
throughput of the ethernet interface with traffic upstream.

Is it possible that these offload mechanism don't work fine with the 
sky2 driver?

Thanks,

Rafa

^ permalink raw reply

* OFFIZIELLE GEWINNBENACHRITIGUNG
From: LOTTERIA LOTTERIA LOTTERIA @ 2017-05-26 17:13 UTC (permalink / raw)


[-- Attachment #1: Type: text/plain, Size: 698 bytes --]

INTERNATIONALE LOTTERIE-PROMOTION
ONLINE LOTTERIE-ABTEILUNG
Referenznummer: CCX-772-876-EM




                                          Gewinnbenachrichtigung



Wir sind verpflichtet, Ihnen mitteilen zu können das Ergebnis der gerechten abgeschlossen monatliche endgültig zieht der Internationale Online Lotterie Promotion und Ihre e-Mail unter den 20 glücklichen Gewinnern gewonnen €2.100,000.00 Euros

für Sicherheit Grund, Lesen Sie die Anlage in PDF Formant für weitere Informationen bezüglich Ihres Gewinns
 
Bitte kontaktieren Sie Herr Josef Feldrich über Ihren Gewinn auf feldrichjosef@gmail.com

Mit freundlichen Grüßen 

HEAD, ONLINE LOTTERY DEPARTMENT
INTERNATIONALE LOTTERY PROMOTIO



[-- Attachment #2: ACHTUNG GEWINNER.pdf --]
[-- Type: application/octet-stream, Size: 661474 bytes --]

^ permalink raw reply

* running an eBPF program
From: Adel Fuchs @ 2017-05-26 11:00 UTC (permalink / raw)
  To: netdev

Hi

I'm trying to run this eBPF program:

https://git.kernel.org/pub/scm/linux/kernel/git/shemminger/iproute2.git/tree/examples/bpf


and I get this error:


:~/iproute2/examples/bpf$sudo tc filter add dev enx00e11100329b parent
1: bpf obj bpf.o exp /tmp/bpf-uds flowid 1:1 action bpf obj bpf.o sec
action-mark            action bpf obj bpf.o sec action-rand ok

[sudo] password for adel:



Prog section 'classifier' rejected: Permission denied (13)!

- Type:         3

- Instructions: 218 (0 over limit)

- License:      GPL



Verifier analysis:



0: (bf) r6 = r1

1: (18) r9 = 0xffe0000e

3: (69) r0 = *(u16 *)(r6 +16)

invalid bpf_context access off=16 size=2



Error fetching program/map!

Failed to retrieve (e)BPF data!


Any suggestions?

Thanks,

Adel

^ permalink raw reply

* Re: [PATCH v2 net-next 1/3] perf, bpf: Add BPF support to all perf_event types
From: kbuild test robot @ 2017-05-26 11:04 UTC (permalink / raw)
  To: Alexei Starovoitov
  Cc: kbuild-all, David S . Miller, Peter Zijlstra, Brendan Gregg,
	Daniel Borkmann, Teng Qin, netdev, linux-kernel
In-Reply-To: <20170526055549.557818-2-ast@fb.com>

[-- Attachment #1: Type: text/plain, Size: 1274 bytes --]

Hi Teng,

[auto build test ERROR on net-next/master]

url:    https://github.com/0day-ci/linux/commits/Alexei-Starovoitov/bpf-Add-BPF-support-to-all-perf_event/20170526-171542
config: ia64-allmodconfig (attached as .config)
compiler: ia64-linux-gcc (GCC) 6.2.0
reproduce:
        wget https://raw.githubusercontent.com/01org/lkp-tests/master/sbin/make.cross -O ~/bin/make.cross
        chmod +x ~/bin/make.cross
        # save the attached .config to linux build tree
        make.cross ARCH=ia64 

All errors (new ones prefixed by >>):

   kernel//bpf/arraymap.c: In function 'perf_event_fd_array_get_ptr':
>> kernel//bpf/arraymap.c:466:11: error: 'struct perf_event' has no member named 'attach_state'
     if (event->attach_state & PERF_ATTACH_TASK)
              ^~

vim +466 kernel//bpf/arraymap.c

   460		if (IS_ERR(perf_file))
   461			return perf_file;
   462	
   463		event = perf_file->private_data;
   464		ee = ERR_PTR(-EINVAL);
   465		/* Per-task events are not supported */
 > 466		if (event->attach_state & PERF_ATTACH_TASK)
   467			goto err_out;
   468	
   469		attr = perf_event_attrs(event);

---
0-DAY kernel test infrastructure                Open Source Technology Center
https://lists.01.org/pipermail/kbuild-all                   Intel Corporation

[-- Attachment #2: .config.gz --]
[-- Type: application/gzip, Size: 47722 bytes --]

^ permalink raw reply

* Re: [for-next 5/6] net/mlx5: Bump driver version
From: Dennis Dalessandro @ 2017-05-26 12:56 UTC (permalink / raw)
  To: Saeed Mahameed, David S. Miller, Doug Ledford
  Cc: netdev-u79uwXL29TY76Z2rM5mHXA, linux-rdma-u79uwXL29TY76Z2rM5mHXA,
	Ilan Tayari, Tariq Toukan
In-Reply-To: <20170523114404.20387-6-saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

On 5/23/2017 7:44 AM, Saeed Mahameed wrote:
> From: Tariq Toukan <tariqt-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> 
> Remove date and bump version for mlx5_core driver.
> 
> Signed-off-by: Tariq Toukan <tariqt-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>
> Signed-off-by: Saeed Mahameed <saeedm-VPRAkNaXOzVWk0Htik3J/w@public.gmane.org>

So I just complained about the bnxt_re doing this. I guess I need to 
raise a flag here too. Now to be clear I'm not against doing this 
version stuff. I'm against using it for some internal tracking that is 
meaningless to the kernel community.

There is no detail in your commit message as to what this driver version 
is used for. Can you please explain how your use of driver version is 
valid while theirs is not?

I realize Dave has already pulled this and I'm not asking for it to be 
reverted but maybe some discussion will help guide future patch 
submissions which do this stuff.

-Denny
--
To unsubscribe from this list: send the line "unsubscribe linux-rdma" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* [PATCH net-next 0/2] ndisc.c minor clean and improvement
From: yuan linyu @ 2017-05-26 13:21 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Joe Perches, David Ahern, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

1. fix part of checkpatch issue which I like to fix
2. __ndisc_fill_addr_option() clean

yuan linyu (2):
  net: ndisc.c: fix coding style issue
  net: ndisc.c: minor code improvement

 net/ipv6/ndisc.c | 139 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 70 insertions(+), 69 deletions(-)

-- 
2.7.4

^ permalink raw reply

* [PATCH net-next 1/2] net: ndisc.c: fix coding style issue
From: yuan linyu @ 2017-05-26 13:23 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Joe Perches, David Ahern, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
 net/ipv6/ndisc.c | 109 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 55 insertions(+), 54 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..292c827 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -99,7 +99,6 @@ static const struct neigh_ops ndisc_hh_ops = {
 	.connected_output =	neigh_resolve_output,
 };
 
-
 static const struct neigh_ops ndisc_direct_ops = {
 	.family =		AF_INET6,
 	.output =		neigh_direct_output,
@@ -147,13 +146,13 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 	u8 *opt = skb_put(skb, space);
 
 	opt[0] = type;
-	opt[1] = space>>3;
+	opt[1] = space >> 3;
 
 	memset(opt + 2, 0, pad);
 	opt   += pad;
 	space -= pad;
 
-	memcpy(opt+2, data, data_len);
+	memcpy(opt + 2, data, data_len);
 	data_len += 2;
 	opt += data_len;
 	space -= data_len;
@@ -182,6 +181,7 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
 					    struct nd_opt_hdr *end)
 {
 	int type;
+
 	if (!cur || !end || cur >= end)
 		return NULL;
 	type = cur->nd_opt_type;
@@ -222,6 +222,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
 	memset(ndopts, 0, sizeof(*ndopts));
 	while (opt_len) {
 		int l;
+
 		if (opt_len < sizeof(struct nd_opt_hdr))
 			return NULL;
 		l = nd_opt->nd_opt_len << 3;
@@ -327,9 +328,8 @@ static int ndisc_constructor(struct neighbour *neigh)
 	bool is_multicast = ipv6_addr_is_multicast(addr);
 
 	in6_dev = in6_dev_get(dev);
-	if (!in6_dev) {
+	if (!in6_dev)
 		return -EINVAL;
-	}
 
 	parms = in6_dev->nd_parms;
 	__neigh_parms_put(neigh->parms);
@@ -344,12 +344,12 @@ static int ndisc_constructor(struct neighbour *neigh)
 		if (is_multicast) {
 			neigh->nud_state = NUD_NOARP;
 			ndisc_mc_map(addr, neigh->ha, dev, 1);
-		} else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
+		} else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
 			neigh->nud_state = NUD_NOARP;
 			memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
-			if (dev->flags&IFF_LOOPBACK)
+			if (dev->flags & IFF_LOOPBACK)
 				neigh->type = RTN_LOCAL;
-		} else if (dev->flags&IFF_POINTOPOINT) {
+		} else if (dev->flags & IFF_POINTOPOINT) {
 			neigh->nud_state = NUD_NOARP;
 			memcpy(neigh->ha, dev->broadcast, dev->addr_len);
 		}
@@ -357,7 +357,7 @@ static int ndisc_constructor(struct neighbour *neigh)
 			neigh->ops = &ndisc_hh_ops;
 		else
 			neigh->ops = &ndisc_generic_ops;
-		if (neigh->nud_state&NUD_VALID)
+		if (neigh->nud_state & NUD_VALID)
 			neigh->output = neigh->ops->connected_output;
 		else
 			neigh->output = neigh->ops->output;
@@ -580,7 +580,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
 
 	if (!saddr) {
 		if (ipv6_get_lladdr(dev, &addr_buf,
-				   (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)))
+				   (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)))
 			return;
 		saddr = &addr_buf;
 	}
@@ -641,9 +641,8 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 		struct inet6_ifaddr *ifp = ipv6_get_ifaddr(dev_net(dev), saddr,
 							   dev, 1);
 		if (ifp) {
-			if (ifp->flags & IFA_F_OPTIMISTIC)  {
+			if (ifp->flags & IFA_F_OPTIMISTIC)
 				send_sllao = 0;
-			}
 			in6_ifa_put(ifp);
 		} else {
 			send_sllao = 0;
@@ -672,7 +671,6 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 	ndisc_send_skb(skb, daddr, saddr);
 }
 
-
 static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
 {
 	/*
@@ -695,7 +693,7 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
 
 	if (skb && ipv6_chk_addr_and_flags(dev_net(dev), &ipv6_hdr(skb)->saddr,
 					   dev, 1,
-					   IFA_F_TENTATIVE|IFA_F_OPTIMISTIC))
+					   IFA_F_TENTATIVE | IFA_F_OPTIMISTIC))
 		saddr = &ipv6_hdr(skb)->saddr;
 	probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
 	if (probes < 0) {
@@ -806,7 +804,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
 	if (ifp) {
 have_ifp:
-		if (ifp->flags & (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)) {
+		if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)) {
 			if (dad) {
 				if (nonce != 0 && ifp->dad_nonce == nonce) {
 					u8 *np = (u8 *)&nonce;
@@ -824,16 +822,15 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 				 */
 				addrconf_dad_failure(ifp);
 				return;
-			} else {
-				/*
-				 * This is not a dad solicitation.
-				 * If we are an optimistic node,
-				 * we should respond.
-				 * Otherwise, we should ignore it.
-				 */
-				if (!(ifp->flags & IFA_F_OPTIMISTIC))
-					goto out;
 			}
+			/*
+			 * This is not a dad solicitation.
+			 * If we are an optimistic node,
+			 * we should respond.
+			 * Otherwise, we should ignore it.
+			 */
+			if (!(ifp->flags & IFA_F_OPTIMISTIC))
+				goto out;
 		}
 
 		idev = ifp->idev;
@@ -874,6 +871,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 				 * (RFC2461) -- yoshfuji
 				 */
 				struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
+
 				if (n)
 					pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
 				goto out;
@@ -904,7 +902,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 			       !inc || lladdr || !dev->addr_len);
 	if (neigh)
 		ndisc_update(dev, neigh, lladdr, NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
+			     NEIGH_UPDATE_F_WEAK_OVERRIDE |
 			     NEIGH_UPDATE_F_OVERRIDE,
 			     NDISC_NEIGHBOUR_SOLICITATION, &ndopts);
 	if (neigh || !dev->header_ops) {
@@ -973,10 +971,10 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	}
 	ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
 	if (ifp) {
-		if (skb->pkt_type != PACKET_LOOPBACK
-		    && (ifp->flags & IFA_F_TENTATIVE)) {
-				addrconf_dad_failure(ifp);
-				return;
+		if (skb->pkt_type != PACKET_LOOPBACK &&
+		    (ifp->flags & IFA_F_TENTATIVE)) {
+			addrconf_dad_failure(ifp);
+			return;
 		}
 		/* What should we make now? The advertisement
 		   is invalid, but ndisc specs say nothing
@@ -1081,8 +1079,8 @@ static void ndisc_recv_rs(struct sk_buff *skb)
 	neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
 	if (neigh) {
 		ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
-			     NEIGH_UPDATE_F_OVERRIDE|
+			     NEIGH_UPDATE_F_WEAK_OVERRIDE |
+			     NEIGH_UPDATE_F_OVERRIDE |
 			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER,
 			     NDISC_ROUTER_SOLICITATION, &ndopts);
 		neigh_release(neigh);
@@ -1110,9 +1108,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
 	}
 
 	nlh = nlmsg_put(skb, 0, 0, RTM_NEWNDUSEROPT, base_size, 0);
-	if (!nlh) {
+	if (!nlh)
 		goto nla_put_failure;
-	}
 
 	ndmsg = nlmsg_data(nlh);
 	ndmsg->nduseropt_family = AF_INET6;
@@ -1325,21 +1322,21 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	if (in6_dev->nd_parms) {
 		unsigned long rtime = ntohl(ra_msg->retrans_timer);
 
-		if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
-			rtime = (rtime*HZ)/1000;
-			if (rtime < HZ/10)
-				rtime = HZ/10;
+		if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ) {
+			rtime = (rtime * HZ) / 1000;
+			if (rtime < HZ / 10)
+				rtime = HZ / 10;
 			NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
 			in6_dev->tstamp = jiffies;
 			send_ifinfo_notify = true;
 		}
 
 		rtime = ntohl(ra_msg->reachable_time);
-		if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
-			rtime = (rtime*HZ)/1000;
+		if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / (3 * HZ)) {
+			rtime = (rtime * HZ) / 1000;
 
-			if (rtime < HZ/10)
-				rtime = HZ/10;
+			if (rtime < HZ / 10)
+				rtime = HZ / 10;
 
 			if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) {
 				NEIGH_VAR_SET(in6_dev->nd_parms,
@@ -1370,6 +1367,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 				       skb->dev, 1);
 	if (neigh) {
 		u8 *lladdr = NULL;
+
 		if (ndopts.nd_opts_src_lladdr) {
 			lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
 						     skb->dev);
@@ -1380,9 +1378,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 			}
 		}
 		ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
-			     NEIGH_UPDATE_F_OVERRIDE|
-			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
+			     NEIGH_UPDATE_F_WEAK_OVERRIDE |
+			     NEIGH_UPDATE_F_OVERRIDE |
+			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
 			     NEIGH_UPDATE_F_ISROUTER,
 			     NDISC_ROUTER_ADVERTISEMENT, &ndopts);
 	}
@@ -1406,6 +1404,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 
 	if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
 		struct nd_opt_hdr *p;
+
 		for (p = ndopts.nd_opts_ri;
 		     p;
 		     p = ndisc_next_option(p, ndopts.nd_opts_ri_end)) {
@@ -1442,6 +1441,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 
 	if (in6_dev->cnf.accept_ra_pinfo && ndopts.nd_opts_pi) {
 		struct nd_opt_hdr *p;
+
 		for (p = ndopts.nd_opts_pi;
 		     p;
 		     p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
@@ -1455,7 +1455,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 		__be32 n;
 		u32 mtu;
 
-		memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
+		memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu + 1)) + 2, sizeof(mtu));
 		mtu = ntohl(n);
 
 		if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
@@ -1472,6 +1472,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 
 	if (ndopts.nd_useropts) {
 		struct nd_opt_hdr *p;
+
 		for (p = ndopts.nd_useropts;
 		     p;
 		     p = ndisc_next_useropt(skb->dev, p,
@@ -1480,9 +1481,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 		}
 	}
 
-	if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
+	if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh)
 		ND_PRINTK(2, warn, "RA: invalid RA options\n");
-	}
 out:
 	ip6_rt_put(rt);
 	if (neigh)
@@ -1518,7 +1518,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 
 	if (!ndopts.nd_opts_rh) {
 		ip6_redirect_no_header(skb, dev_net(skb->dev),
-					skb->dev->ifindex, 0);
+				       skb->dev->ifindex, 0);
 		return;
 	}
 
@@ -1569,7 +1569,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	}
 
 	if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
-	    ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
+	    ipv6_addr_type(target) != (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
 		ND_PRINTK(2, warn,
 			  "Redirect: target address is not link-local unicast\n");
 		return;
@@ -1587,7 +1587,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	if (IS_ERR(dst))
 		return;
 
-	rt = (struct rt6_info *) dst;
+	rt = (struct rt6_info *)dst;
 
 	if (rt->rt6i_flags & RTF_GATEWAY) {
 		ND_PRINTK(2, warn,
@@ -1595,7 +1595,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 		goto release;
 	}
 	peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr, 1);
-	ret = inet_peer_xrlim_allow(peer, 1*HZ);
+	ret = inet_peer_xrlim_allow(peer, 1 * HZ);
 	if (peer)
 		inet_putpeer(peer);
 	if (!ret)
@@ -1603,6 +1603,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 
 	if (dev->addr_len) {
 		struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
+
 		if (!neigh) {
 			ND_PRINTK(2, warn,
 				  "Redirect: no neigh for target address\n");
@@ -1787,6 +1788,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
 {
 	static char warncomm[TASK_COMM_LEN];
 	static int warned;
+
 	if (strcmp(warncomm, current->comm) && warned < 5) {
 		strcpy(warncomm, current->comm);
 		pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
@@ -1797,7 +1799,8 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
 	}
 }
 
-int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
+int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
+			       void __user *buffer, size_t *lenp, loff_t *ppos)
 {
 	struct net_device *dev = ctl->extra1;
 	struct inet6_dev *idev;
@@ -1831,8 +1834,6 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
 	}
 	return ret;
 }
-
-
 #endif
 
 static int __net_init ndisc_net_init(struct net *net)
-- 
2.7.4

^ permalink raw reply related

* [PATCH net-next 2/2] net: ndisc.c: minor code improvement
From: yuan linyu @ 2017-05-26 13:24 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Joe Perches, David Ahern, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

on x86_64, text size decrease 80 bytes

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
 net/ipv6/ndisc.c | 32 ++++++++++++++++----------------
 1 file changed, 16 insertions(+), 16 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 292c827..ee9b12c 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -147,17 +147,16 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 
 	opt[0] = type;
 	opt[1] = space >> 3;
+	opt   += 2;
 
-	memset(opt + 2, 0, pad);
+	memset(opt, 0, pad);
 	opt   += pad;
 	space -= pad;
 
-	memcpy(opt + 2, data, data_len);
-	data_len += 2;
+	memcpy(opt, data, data_len);
 	opt += data_len;
 	space -= data_len;
-	if (space > 0)
-		memset(opt, 0, space);
+	memset(opt, 0, space);
 }
 EXPORT_SYMBOL_GPL(__ndisc_fill_addr_option);
 
@@ -997,6 +996,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	if (neigh) {
 		u8 old_flags = neigh->flags;
 		struct net *net = dev_net(dev);
+		u32 flags;
 
 		if (neigh->nud_state & NUD_FAILED)
 			goto out;
@@ -1013,13 +1013,14 @@ static void ndisc_recv_na(struct sk_buff *skb)
 			goto out;
 		}
 
+		flags = NEIGH_UPDATE_F_WEAK_OVERRIDE | NEIGH_UPDATE_F_OVERRIDE_ISROUTER;
+		if (msg->icmph.icmp6_override)
+			flags |= NEIGH_UPDATE_F_OVERRIDE;
+		if (msg->icmph.icmp6_router)
+			flags |= NEIGH_UPDATE_F_ISROUTER;
 		ndisc_update(dev, neigh, lladdr,
 			     msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
-			     (msg->icmph.icmp6_override ? NEIGH_UPDATE_F_OVERRIDE : 0)|
-			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
-			     (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0),
-			     NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
+			     flags, NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
 
 		if ((old_flags & ~neigh->flags) & NTF_ROUTER) {
 			/*
@@ -1217,12 +1218,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	 * received RA message (RFC 2462) -- yoshfuji
 	 */
 	old_if_flags = in6_dev->if_flags;
-	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
-				IF_RA_OTHERCONF)) |
-				(ra_msg->icmph.icmp6_addrconf_managed ?
-					IF_RA_MANAGED : 0) |
-				(ra_msg->icmph.icmp6_addrconf_other ?
-					IF_RA_OTHERCONF : 0);
+	in6_dev->if_flags &= ~(IF_RA_MANAGED | IF_RA_OTHERCONF);
+	if (ra_msg->icmph.icmp6_addrconf_managed)
+		in6_dev->if_flags |= IF_RA_MANAGED;
+	if (ra_msg->icmph.icmp6_addrconf_other)
+		in6_dev->if_flags |= IF_RA_OTHERCONF;
 
 	if (old_if_flags != in6_dev->if_flags)
 		send_ifinfo_notify = true;
-- 
2.7.4

^ permalink raw reply related

* Re: [PATCH v3 2/2] dt-bindings: net: Add Cortina device tree bindings
From: Andrew Lunn @ 2017-05-26 13:35 UTC (permalink / raw)
  To: Bogdan Purcareata
  Cc: f.fainelli-Re5JQEeQqe8AvxtiuMwx3w, netdev-u79uwXL29TY76Z2rM5mHXA,
	devicetree-u79uwXL29TY76Z2rM5mHXA,
	linux-kernel-u79uwXL29TY76Z2rM5mHXA
In-Reply-To: <1495785519-1468-3-git-send-email-bogdan.purcareata-3arQi8VN3Tc@public.gmane.org>

> +		cs4340_phy@1 {
> +			compatible = "ethernet-phy-id13e5.1002";
> +			reg = <0x10>;

The @1 and the reg value should be the same. Please change it to
cs4340_phy@10.

    Andrew
--
To unsubscribe from this list: send the line "unsubscribe devicetree" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at  http://vger.kernel.org/majordomo-info.html

^ permalink raw reply

* RE: [PATCH v3 2/2] dt-bindings: net: Add Cortina device tree bindings
From: Bogdan Purcareata @ 2017-05-26 13:41 UTC (permalink / raw)
  To: Andrew Lunn
  Cc: f.fainelli@gmail.com, netdev@vger.kernel.org,
	devicetree@vger.kernel.org, linux-kernel@vger.kernel.org
In-Reply-To: <20170526133554.GD31389@lunn.ch>

> -----Original Message-----
> From: Andrew Lunn [mailto:andrew@lunn.ch]
> Sent: Friday, May 26, 2017 4:36 PM
> To: Bogdan Purcareata <bogdan.purcareata@nxp.com>
> Cc: f.fainelli@gmail.com; netdev@vger.kernel.org;
> devicetree@vger.kernel.org; linux-kernel@vger.kernel.org
> Subject: Re: [PATCH v3 2/2] dt-bindings: net: Add Cortina device tree
> bindings
> 
> > +		cs4340_phy@1 {
> > +			compatible = "ethernet-phy-id13e5.1002";
> > +			reg = <0x10>;
> 
> The @1 and the reg value should be the same. Please change it to
> cs4340_phy@10.

Will do, thanks!
Bogdan

^ permalink raw reply

* Re: [PATCH net-next 1/2] net: ndisc.c: fix coding style issue
From: 吉藤英明 @ 2017-05-26 13:45 UTC (permalink / raw)
  To: yuan linyu
  Cc: network dev, David S . Miller, Joe Perches, David Ahern,
	yuan linyu, YOSHIFUJI Hideaki
In-Reply-To: <1495805019-2919-1-git-send-email-cugyly@163.com>

Hi,

2017-05-26 22:23 GMT+09:00 yuan linyu <cugyly@163.com>:
> From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
>
> Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> ---
>  net/ipv6/ndisc.c | 109 ++++++++++++++++++++++++++++---------------------------
>  1 file changed, 55 insertions(+), 54 deletions(-)

Sorry, I don't think this kind of change for style is good
bacause this makes effort of  backport more difficult.

--yoshfuji

>
> diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
> index d310dc4..292c827 100644
> --- a/net/ipv6/ndisc.c
> +++ b/net/ipv6/ndisc.c
> @@ -99,7 +99,6 @@ static const struct neigh_ops ndisc_hh_ops = {
>         .connected_output =     neigh_resolve_output,
>  };
>
> -
>  static const struct neigh_ops ndisc_direct_ops = {
>         .family =               AF_INET6,
>         .output =               neigh_direct_output,
> @@ -147,13 +146,13 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
>         u8 *opt = skb_put(skb, space);
>
>         opt[0] = type;
> -       opt[1] = space>>3;
> +       opt[1] = space >> 3;
>
>         memset(opt + 2, 0, pad);
>         opt   += pad;
>         space -= pad;
>
> -       memcpy(opt+2, data, data_len);
> +       memcpy(opt + 2, data, data_len);
>         data_len += 2;
>         opt += data_len;
>         space -= data_len;
> @@ -182,6 +181,7 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
>                                             struct nd_opt_hdr *end)
>  {
>         int type;
> +
>         if (!cur || !end || cur >= end)
>                 return NULL;
>         type = cur->nd_opt_type;
> @@ -222,6 +222,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
>         memset(ndopts, 0, sizeof(*ndopts));
>         while (opt_len) {
>                 int l;
> +
>                 if (opt_len < sizeof(struct nd_opt_hdr))
>                         return NULL;
>                 l = nd_opt->nd_opt_len << 3;
> @@ -327,9 +328,8 @@ static int ndisc_constructor(struct neighbour *neigh)
>         bool is_multicast = ipv6_addr_is_multicast(addr);
>
>         in6_dev = in6_dev_get(dev);
> -       if (!in6_dev) {
> +       if (!in6_dev)
>                 return -EINVAL;
> -       }
>
>         parms = in6_dev->nd_parms;
>         __neigh_parms_put(neigh->parms);
> @@ -344,12 +344,12 @@ static int ndisc_constructor(struct neighbour *neigh)
>                 if (is_multicast) {
>                         neigh->nud_state = NUD_NOARP;
>                         ndisc_mc_map(addr, neigh->ha, dev, 1);
> -               } else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
> +               } else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
>                         neigh->nud_state = NUD_NOARP;
>                         memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
> -                       if (dev->flags&IFF_LOOPBACK)
> +                       if (dev->flags & IFF_LOOPBACK)
>                                 neigh->type = RTN_LOCAL;
> -               } else if (dev->flags&IFF_POINTOPOINT) {
> +               } else if (dev->flags & IFF_POINTOPOINT) {
>                         neigh->nud_state = NUD_NOARP;
>                         memcpy(neigh->ha, dev->broadcast, dev->addr_len);
>                 }
> @@ -357,7 +357,7 @@ static int ndisc_constructor(struct neighbour *neigh)
>                         neigh->ops = &ndisc_hh_ops;
>                 else
>                         neigh->ops = &ndisc_generic_ops;
> -               if (neigh->nud_state&NUD_VALID)
> +               if (neigh->nud_state & NUD_VALID)
>                         neigh->output = neigh->ops->connected_output;
>                 else
>                         neigh->output = neigh->ops->output;
> @@ -580,7 +580,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
>
>         if (!saddr) {
>                 if (ipv6_get_lladdr(dev, &addr_buf,
> -                                  (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)))
> +                                  (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)))
>                         return;
>                 saddr = &addr_buf;
>         }
> @@ -641,9 +641,8 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
>                 struct inet6_ifaddr *ifp = ipv6_get_ifaddr(dev_net(dev), saddr,
>                                                            dev, 1);
>                 if (ifp) {
> -                       if (ifp->flags & IFA_F_OPTIMISTIC)  {
> +                       if (ifp->flags & IFA_F_OPTIMISTIC)
>                                 send_sllao = 0;
> -                       }
>                         in6_ifa_put(ifp);
>                 } else {
>                         send_sllao = 0;
> @@ -672,7 +671,6 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
>         ndisc_send_skb(skb, daddr, saddr);
>  }
>
> -
>  static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
>  {
>         /*
> @@ -695,7 +693,7 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
>
>         if (skb && ipv6_chk_addr_and_flags(dev_net(dev), &ipv6_hdr(skb)->saddr,
>                                            dev, 1,
> -                                          IFA_F_TENTATIVE|IFA_F_OPTIMISTIC))
> +                                          IFA_F_TENTATIVE | IFA_F_OPTIMISTIC))
>                 saddr = &ipv6_hdr(skb)->saddr;
>         probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
>         if (probes < 0) {
> @@ -806,7 +804,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
>         ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
>         if (ifp) {
>  have_ifp:
> -               if (ifp->flags & (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)) {
> +               if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)) {
>                         if (dad) {
>                                 if (nonce != 0 && ifp->dad_nonce == nonce) {
>                                         u8 *np = (u8 *)&nonce;
> @@ -824,16 +822,15 @@ static void ndisc_recv_ns(struct sk_buff *skb)
>                                  */
>                                 addrconf_dad_failure(ifp);
>                                 return;
> -                       } else {
> -                               /*
> -                                * This is not a dad solicitation.
> -                                * If we are an optimistic node,
> -                                * we should respond.
> -                                * Otherwise, we should ignore it.
> -                                */
> -                               if (!(ifp->flags & IFA_F_OPTIMISTIC))
> -                                       goto out;
>                         }
> +                       /*
> +                        * This is not a dad solicitation.
> +                        * If we are an optimistic node,
> +                        * we should respond.
> +                        * Otherwise, we should ignore it.
> +                        */
> +                       if (!(ifp->flags & IFA_F_OPTIMISTIC))
> +                               goto out;
>                 }
>
>                 idev = ifp->idev;
> @@ -874,6 +871,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
>                                  * (RFC2461) -- yoshfuji
>                                  */
>                                 struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
> +
>                                 if (n)
>                                         pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
>                                 goto out;
> @@ -904,7 +902,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
>                                !inc || lladdr || !dev->addr_len);
>         if (neigh)
>                 ndisc_update(dev, neigh, lladdr, NUD_STALE,
> -                            NEIGH_UPDATE_F_WEAK_OVERRIDE|
> +                            NEIGH_UPDATE_F_WEAK_OVERRIDE |
>                              NEIGH_UPDATE_F_OVERRIDE,
>                              NDISC_NEIGHBOUR_SOLICITATION, &ndopts);
>         if (neigh || !dev->header_ops) {
> @@ -973,10 +971,10 @@ static void ndisc_recv_na(struct sk_buff *skb)
>         }
>         ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
>         if (ifp) {
> -               if (skb->pkt_type != PACKET_LOOPBACK
> -                   && (ifp->flags & IFA_F_TENTATIVE)) {
> -                               addrconf_dad_failure(ifp);
> -                               return;
> +               if (skb->pkt_type != PACKET_LOOPBACK &&
> +                   (ifp->flags & IFA_F_TENTATIVE)) {
> +                       addrconf_dad_failure(ifp);
> +                       return;
>                 }
>                 /* What should we make now? The advertisement
>                    is invalid, but ndisc specs say nothing
> @@ -1081,8 +1079,8 @@ static void ndisc_recv_rs(struct sk_buff *skb)
>         neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
>         if (neigh) {
>                 ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
> -                            NEIGH_UPDATE_F_WEAK_OVERRIDE|
> -                            NEIGH_UPDATE_F_OVERRIDE|
> +                            NEIGH_UPDATE_F_WEAK_OVERRIDE |
> +                            NEIGH_UPDATE_F_OVERRIDE |
>                              NEIGH_UPDATE_F_OVERRIDE_ISROUTER,
>                              NDISC_ROUTER_SOLICITATION, &ndopts);
>                 neigh_release(neigh);
> @@ -1110,9 +1108,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
>         }
>
>         nlh = nlmsg_put(skb, 0, 0, RTM_NEWNDUSEROPT, base_size, 0);
> -       if (!nlh) {
> +       if (!nlh)
>                 goto nla_put_failure;
> -       }
>
>         ndmsg = nlmsg_data(nlh);
>         ndmsg->nduseropt_family = AF_INET6;
> @@ -1325,21 +1322,21 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>         if (in6_dev->nd_parms) {
>                 unsigned long rtime = ntohl(ra_msg->retrans_timer);
>
> -               if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
> -                       rtime = (rtime*HZ)/1000;
> -                       if (rtime < HZ/10)
> -                               rtime = HZ/10;
> +               if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ) {
> +                       rtime = (rtime * HZ) / 1000;
> +                       if (rtime < HZ / 10)
> +                               rtime = HZ / 10;
>                         NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
>                         in6_dev->tstamp = jiffies;
>                         send_ifinfo_notify = true;
>                 }
>
>                 rtime = ntohl(ra_msg->reachable_time);
> -               if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
> -                       rtime = (rtime*HZ)/1000;
> +               if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / (3 * HZ)) {
> +                       rtime = (rtime * HZ) / 1000;
>
> -                       if (rtime < HZ/10)
> -                               rtime = HZ/10;
> +                       if (rtime < HZ / 10)
> +                               rtime = HZ / 10;
>
>                         if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) {
>                                 NEIGH_VAR_SET(in6_dev->nd_parms,
> @@ -1370,6 +1367,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>                                        skb->dev, 1);
>         if (neigh) {
>                 u8 *lladdr = NULL;
> +
>                 if (ndopts.nd_opts_src_lladdr) {
>                         lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
>                                                      skb->dev);
> @@ -1380,9 +1378,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>                         }
>                 }
>                 ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
> -                            NEIGH_UPDATE_F_WEAK_OVERRIDE|
> -                            NEIGH_UPDATE_F_OVERRIDE|
> -                            NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
> +                            NEIGH_UPDATE_F_WEAK_OVERRIDE |
> +                            NEIGH_UPDATE_F_OVERRIDE |
> +                            NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
>                              NEIGH_UPDATE_F_ISROUTER,
>                              NDISC_ROUTER_ADVERTISEMENT, &ndopts);
>         }
> @@ -1406,6 +1404,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>
>         if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
>                 struct nd_opt_hdr *p;
> +
>                 for (p = ndopts.nd_opts_ri;
>                      p;
>                      p = ndisc_next_option(p, ndopts.nd_opts_ri_end)) {
> @@ -1442,6 +1441,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>
>         if (in6_dev->cnf.accept_ra_pinfo && ndopts.nd_opts_pi) {
>                 struct nd_opt_hdr *p;
> +
>                 for (p = ndopts.nd_opts_pi;
>                      p;
>                      p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
> @@ -1455,7 +1455,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>                 __be32 n;
>                 u32 mtu;
>
> -               memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
> +               memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu + 1)) + 2, sizeof(mtu));
>                 mtu = ntohl(n);
>
>                 if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
> @@ -1472,6 +1472,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>
>         if (ndopts.nd_useropts) {
>                 struct nd_opt_hdr *p;
> +
>                 for (p = ndopts.nd_useropts;
>                      p;
>                      p = ndisc_next_useropt(skb->dev, p,
> @@ -1480,9 +1481,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
>                 }
>         }
>
> -       if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
> +       if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh)
>                 ND_PRINTK(2, warn, "RA: invalid RA options\n");
> -       }
>  out:
>         ip6_rt_put(rt);
>         if (neigh)
> @@ -1518,7 +1518,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
>
>         if (!ndopts.nd_opts_rh) {
>                 ip6_redirect_no_header(skb, dev_net(skb->dev),
> -                                       skb->dev->ifindex, 0);
> +                                      skb->dev->ifindex, 0);
>                 return;
>         }
>
> @@ -1569,7 +1569,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
>         }
>
>         if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
> -           ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
> +           ipv6_addr_type(target) != (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
>                 ND_PRINTK(2, warn,
>                           "Redirect: target address is not link-local unicast\n");
>                 return;
> @@ -1587,7 +1587,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
>         if (IS_ERR(dst))
>                 return;
>
> -       rt = (struct rt6_info *) dst;
> +       rt = (struct rt6_info *)dst;
>
>         if (rt->rt6i_flags & RTF_GATEWAY) {
>                 ND_PRINTK(2, warn,
> @@ -1595,7 +1595,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
>                 goto release;
>         }
>         peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr, 1);
> -       ret = inet_peer_xrlim_allow(peer, 1*HZ);
> +       ret = inet_peer_xrlim_allow(peer, 1 * HZ);
>         if (peer)
>                 inet_putpeer(peer);
>         if (!ret)
> @@ -1603,6 +1603,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
>
>         if (dev->addr_len) {
>                 struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
> +
>                 if (!neigh) {
>                         ND_PRINTK(2, warn,
>                                   "Redirect: no neigh for target address\n");
> @@ -1787,6 +1788,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
>  {
>         static char warncomm[TASK_COMM_LEN];
>         static int warned;
> +
>         if (strcmp(warncomm, current->comm) && warned < 5) {
>                 strcpy(warncomm, current->comm);
>                 pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
> @@ -1797,7 +1799,8 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
>         }
>  }
>
> -int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
> +int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
> +                              void __user *buffer, size_t *lenp, loff_t *ppos)
>  {
>         struct net_device *dev = ctl->extra1;
>         struct inet6_dev *idev;
> @@ -1831,8 +1834,6 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
>         }
>         return ret;
>  }
> -
> -
>  #endif
>
>  static int __net_init ndisc_net_init(struct net *net)
> --
> 2.7.4
>
>

^ permalink raw reply

* [PATCH net-next v1 0/2] ndisc.c minor clean and improvement
From: yuan linyu @ 2017-05-26 13:46 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Joe Perches, David Ahern, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

1. fix part of checkpatch issue which I like to fix
2. __ndisc_fill_addr_option() clean

v1:
correct space value

yuan linyu (2):
  net: ndisc.c: fix coding style issue
  net: ndisc.c: minor code improvement

 net/ipv6/ndisc.c | 141 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 72 insertions(+), 69 deletions(-)

-- 
2.7.4

^ permalink raw reply

* [PATCH net-next v1 1/2] net: ndisc.c: fix coding style issue
From: yuan linyu @ 2017-05-26 13:47 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Joe Perches, David Ahern, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
 net/ipv6/ndisc.c | 109 ++++++++++++++++++++++++++++---------------------------
 1 file changed, 55 insertions(+), 54 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index d310dc4..292c827 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -99,7 +99,6 @@ static const struct neigh_ops ndisc_hh_ops = {
 	.connected_output =	neigh_resolve_output,
 };
 
-
 static const struct neigh_ops ndisc_direct_ops = {
 	.family =		AF_INET6,
 	.output =		neigh_direct_output,
@@ -147,13 +146,13 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 	u8 *opt = skb_put(skb, space);
 
 	opt[0] = type;
-	opt[1] = space>>3;
+	opt[1] = space >> 3;
 
 	memset(opt + 2, 0, pad);
 	opt   += pad;
 	space -= pad;
 
-	memcpy(opt+2, data, data_len);
+	memcpy(opt + 2, data, data_len);
 	data_len += 2;
 	opt += data_len;
 	space -= data_len;
@@ -182,6 +181,7 @@ static struct nd_opt_hdr *ndisc_next_option(struct nd_opt_hdr *cur,
 					    struct nd_opt_hdr *end)
 {
 	int type;
+
 	if (!cur || !end || cur >= end)
 		return NULL;
 	type = cur->nd_opt_type;
@@ -222,6 +222,7 @@ struct ndisc_options *ndisc_parse_options(const struct net_device *dev,
 	memset(ndopts, 0, sizeof(*ndopts));
 	while (opt_len) {
 		int l;
+
 		if (opt_len < sizeof(struct nd_opt_hdr))
 			return NULL;
 		l = nd_opt->nd_opt_len << 3;
@@ -327,9 +328,8 @@ static int ndisc_constructor(struct neighbour *neigh)
 	bool is_multicast = ipv6_addr_is_multicast(addr);
 
 	in6_dev = in6_dev_get(dev);
-	if (!in6_dev) {
+	if (!in6_dev)
 		return -EINVAL;
-	}
 
 	parms = in6_dev->nd_parms;
 	__neigh_parms_put(neigh->parms);
@@ -344,12 +344,12 @@ static int ndisc_constructor(struct neighbour *neigh)
 		if (is_multicast) {
 			neigh->nud_state = NUD_NOARP;
 			ndisc_mc_map(addr, neigh->ha, dev, 1);
-		} else if (dev->flags&(IFF_NOARP|IFF_LOOPBACK)) {
+		} else if (dev->flags & (IFF_NOARP | IFF_LOOPBACK)) {
 			neigh->nud_state = NUD_NOARP;
 			memcpy(neigh->ha, dev->dev_addr, dev->addr_len);
-			if (dev->flags&IFF_LOOPBACK)
+			if (dev->flags & IFF_LOOPBACK)
 				neigh->type = RTN_LOCAL;
-		} else if (dev->flags&IFF_POINTOPOINT) {
+		} else if (dev->flags & IFF_POINTOPOINT) {
 			neigh->nud_state = NUD_NOARP;
 			memcpy(neigh->ha, dev->broadcast, dev->addr_len);
 		}
@@ -357,7 +357,7 @@ static int ndisc_constructor(struct neighbour *neigh)
 			neigh->ops = &ndisc_hh_ops;
 		else
 			neigh->ops = &ndisc_generic_ops;
-		if (neigh->nud_state&NUD_VALID)
+		if (neigh->nud_state & NUD_VALID)
 			neigh->output = neigh->ops->connected_output;
 		else
 			neigh->output = neigh->ops->output;
@@ -580,7 +580,7 @@ void ndisc_send_ns(struct net_device *dev, const struct in6_addr *solicit,
 
 	if (!saddr) {
 		if (ipv6_get_lladdr(dev, &addr_buf,
-				   (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)))
+				   (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)))
 			return;
 		saddr = &addr_buf;
 	}
@@ -641,9 +641,8 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 		struct inet6_ifaddr *ifp = ipv6_get_ifaddr(dev_net(dev), saddr,
 							   dev, 1);
 		if (ifp) {
-			if (ifp->flags & IFA_F_OPTIMISTIC)  {
+			if (ifp->flags & IFA_F_OPTIMISTIC)
 				send_sllao = 0;
-			}
 			in6_ifa_put(ifp);
 		} else {
 			send_sllao = 0;
@@ -672,7 +671,6 @@ void ndisc_send_rs(struct net_device *dev, const struct in6_addr *saddr,
 	ndisc_send_skb(skb, daddr, saddr);
 }
 
-
 static void ndisc_error_report(struct neighbour *neigh, struct sk_buff *skb)
 {
 	/*
@@ -695,7 +693,7 @@ static void ndisc_solicit(struct neighbour *neigh, struct sk_buff *skb)
 
 	if (skb && ipv6_chk_addr_and_flags(dev_net(dev), &ipv6_hdr(skb)->saddr,
 					   dev, 1,
-					   IFA_F_TENTATIVE|IFA_F_OPTIMISTIC))
+					   IFA_F_TENTATIVE | IFA_F_OPTIMISTIC))
 		saddr = &ipv6_hdr(skb)->saddr;
 	probes -= NEIGH_VAR(neigh->parms, UCAST_PROBES);
 	if (probes < 0) {
@@ -806,7 +804,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 	ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
 	if (ifp) {
 have_ifp:
-		if (ifp->flags & (IFA_F_TENTATIVE|IFA_F_OPTIMISTIC)) {
+		if (ifp->flags & (IFA_F_TENTATIVE | IFA_F_OPTIMISTIC)) {
 			if (dad) {
 				if (nonce != 0 && ifp->dad_nonce == nonce) {
 					u8 *np = (u8 *)&nonce;
@@ -824,16 +822,15 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 				 */
 				addrconf_dad_failure(ifp);
 				return;
-			} else {
-				/*
-				 * This is not a dad solicitation.
-				 * If we are an optimistic node,
-				 * we should respond.
-				 * Otherwise, we should ignore it.
-				 */
-				if (!(ifp->flags & IFA_F_OPTIMISTIC))
-					goto out;
 			}
+			/*
+			 * This is not a dad solicitation.
+			 * If we are an optimistic node,
+			 * we should respond.
+			 * Otherwise, we should ignore it.
+			 */
+			if (!(ifp->flags & IFA_F_OPTIMISTIC))
+				goto out;
 		}
 
 		idev = ifp->idev;
@@ -874,6 +871,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 				 * (RFC2461) -- yoshfuji
 				 */
 				struct sk_buff *n = skb_clone(skb, GFP_ATOMIC);
+
 				if (n)
 					pneigh_enqueue(&nd_tbl, idev->nd_parms, n);
 				goto out;
@@ -904,7 +902,7 @@ static void ndisc_recv_ns(struct sk_buff *skb)
 			       !inc || lladdr || !dev->addr_len);
 	if (neigh)
 		ndisc_update(dev, neigh, lladdr, NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
+			     NEIGH_UPDATE_F_WEAK_OVERRIDE |
 			     NEIGH_UPDATE_F_OVERRIDE,
 			     NDISC_NEIGHBOUR_SOLICITATION, &ndopts);
 	if (neigh || !dev->header_ops) {
@@ -973,10 +971,10 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	}
 	ifp = ipv6_get_ifaddr(dev_net(dev), &msg->target, dev, 1);
 	if (ifp) {
-		if (skb->pkt_type != PACKET_LOOPBACK
-		    && (ifp->flags & IFA_F_TENTATIVE)) {
-				addrconf_dad_failure(ifp);
-				return;
+		if (skb->pkt_type != PACKET_LOOPBACK &&
+		    (ifp->flags & IFA_F_TENTATIVE)) {
+			addrconf_dad_failure(ifp);
+			return;
 		}
 		/* What should we make now? The advertisement
 		   is invalid, but ndisc specs say nothing
@@ -1081,8 +1079,8 @@ static void ndisc_recv_rs(struct sk_buff *skb)
 	neigh = __neigh_lookup(&nd_tbl, saddr, skb->dev, 1);
 	if (neigh) {
 		ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
-			     NEIGH_UPDATE_F_OVERRIDE|
+			     NEIGH_UPDATE_F_WEAK_OVERRIDE |
+			     NEIGH_UPDATE_F_OVERRIDE |
 			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER,
 			     NDISC_ROUTER_SOLICITATION, &ndopts);
 		neigh_release(neigh);
@@ -1110,9 +1108,8 @@ static void ndisc_ra_useropt(struct sk_buff *ra, struct nd_opt_hdr *opt)
 	}
 
 	nlh = nlmsg_put(skb, 0, 0, RTM_NEWNDUSEROPT, base_size, 0);
-	if (!nlh) {
+	if (!nlh)
 		goto nla_put_failure;
-	}
 
 	ndmsg = nlmsg_data(nlh);
 	ndmsg->nduseropt_family = AF_INET6;
@@ -1325,21 +1322,21 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	if (in6_dev->nd_parms) {
 		unsigned long rtime = ntohl(ra_msg->retrans_timer);
 
-		if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/HZ) {
-			rtime = (rtime*HZ)/1000;
-			if (rtime < HZ/10)
-				rtime = HZ/10;
+		if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / HZ) {
+			rtime = (rtime * HZ) / 1000;
+			if (rtime < HZ / 10)
+				rtime = HZ / 10;
 			NEIGH_VAR_SET(in6_dev->nd_parms, RETRANS_TIME, rtime);
 			in6_dev->tstamp = jiffies;
 			send_ifinfo_notify = true;
 		}
 
 		rtime = ntohl(ra_msg->reachable_time);
-		if (rtime && rtime/1000 < MAX_SCHEDULE_TIMEOUT/(3*HZ)) {
-			rtime = (rtime*HZ)/1000;
+		if (rtime && rtime / 1000 < MAX_SCHEDULE_TIMEOUT / (3 * HZ)) {
+			rtime = (rtime * HZ) / 1000;
 
-			if (rtime < HZ/10)
-				rtime = HZ/10;
+			if (rtime < HZ / 10)
+				rtime = HZ / 10;
 
 			if (rtime != NEIGH_VAR(in6_dev->nd_parms, BASE_REACHABLE_TIME)) {
 				NEIGH_VAR_SET(in6_dev->nd_parms,
@@ -1370,6 +1367,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 				       skb->dev, 1);
 	if (neigh) {
 		u8 *lladdr = NULL;
+
 		if (ndopts.nd_opts_src_lladdr) {
 			lladdr = ndisc_opt_addr_data(ndopts.nd_opts_src_lladdr,
 						     skb->dev);
@@ -1380,9 +1378,9 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 			}
 		}
 		ndisc_update(skb->dev, neigh, lladdr, NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
-			     NEIGH_UPDATE_F_OVERRIDE|
-			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
+			     NEIGH_UPDATE_F_WEAK_OVERRIDE |
+			     NEIGH_UPDATE_F_OVERRIDE |
+			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER |
 			     NEIGH_UPDATE_F_ISROUTER,
 			     NDISC_ROUTER_ADVERTISEMENT, &ndopts);
 	}
@@ -1406,6 +1404,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 
 	if (in6_dev->cnf.accept_ra_rtr_pref && ndopts.nd_opts_ri) {
 		struct nd_opt_hdr *p;
+
 		for (p = ndopts.nd_opts_ri;
 		     p;
 		     p = ndisc_next_option(p, ndopts.nd_opts_ri_end)) {
@@ -1442,6 +1441,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 
 	if (in6_dev->cnf.accept_ra_pinfo && ndopts.nd_opts_pi) {
 		struct nd_opt_hdr *p;
+
 		for (p = ndopts.nd_opts_pi;
 		     p;
 		     p = ndisc_next_option(p, ndopts.nd_opts_pi_end)) {
@@ -1455,7 +1455,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 		__be32 n;
 		u32 mtu;
 
-		memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu+1))+2, sizeof(mtu));
+		memcpy(&n, ((u8 *)(ndopts.nd_opts_mtu + 1)) + 2, sizeof(mtu));
 		mtu = ntohl(n);
 
 		if (mtu < IPV6_MIN_MTU || mtu > skb->dev->mtu) {
@@ -1472,6 +1472,7 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 
 	if (ndopts.nd_useropts) {
 		struct nd_opt_hdr *p;
+
 		for (p = ndopts.nd_useropts;
 		     p;
 		     p = ndisc_next_useropt(skb->dev, p,
@@ -1480,9 +1481,8 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 		}
 	}
 
-	if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh) {
+	if (ndopts.nd_opts_tgt_lladdr || ndopts.nd_opts_rh)
 		ND_PRINTK(2, warn, "RA: invalid RA options\n");
-	}
 out:
 	ip6_rt_put(rt);
 	if (neigh)
@@ -1518,7 +1518,7 @@ static void ndisc_redirect_rcv(struct sk_buff *skb)
 
 	if (!ndopts.nd_opts_rh) {
 		ip6_redirect_no_header(skb, dev_net(skb->dev),
-					skb->dev->ifindex, 0);
+				       skb->dev->ifindex, 0);
 		return;
 	}
 
@@ -1569,7 +1569,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	}
 
 	if (!ipv6_addr_equal(&ipv6_hdr(skb)->daddr, target) &&
-	    ipv6_addr_type(target) != (IPV6_ADDR_UNICAST|IPV6_ADDR_LINKLOCAL)) {
+	    ipv6_addr_type(target) != (IPV6_ADDR_UNICAST | IPV6_ADDR_LINKLOCAL)) {
 		ND_PRINTK(2, warn,
 			  "Redirect: target address is not link-local unicast\n");
 		return;
@@ -1587,7 +1587,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 	if (IS_ERR(dst))
 		return;
 
-	rt = (struct rt6_info *) dst;
+	rt = (struct rt6_info *)dst;
 
 	if (rt->rt6i_flags & RTF_GATEWAY) {
 		ND_PRINTK(2, warn,
@@ -1595,7 +1595,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 		goto release;
 	}
 	peer = inet_getpeer_v6(net->ipv6.peers, &ipv6_hdr(skb)->saddr, 1);
-	ret = inet_peer_xrlim_allow(peer, 1*HZ);
+	ret = inet_peer_xrlim_allow(peer, 1 * HZ);
 	if (peer)
 		inet_putpeer(peer);
 	if (!ret)
@@ -1603,6 +1603,7 @@ void ndisc_send_redirect(struct sk_buff *skb, const struct in6_addr *target)
 
 	if (dev->addr_len) {
 		struct neighbour *neigh = dst_neigh_lookup(skb_dst(skb), target);
+
 		if (!neigh) {
 			ND_PRINTK(2, warn,
 				  "Redirect: no neigh for target address\n");
@@ -1787,6 +1788,7 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
 {
 	static char warncomm[TASK_COMM_LEN];
 	static int warned;
+
 	if (strcmp(warncomm, current->comm) && warned < 5) {
 		strcpy(warncomm, current->comm);
 		pr_warn("process `%s' is using deprecated sysctl (%s) net.ipv6.neigh.%s.%s - use net.ipv6.neigh.%s.%s_ms instead\n",
@@ -1797,7 +1799,8 @@ static void ndisc_warn_deprecated_sysctl(struct ctl_table *ctl,
 	}
 }
 
-int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *buffer, size_t *lenp, loff_t *ppos)
+int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write,
+			       void __user *buffer, size_t *lenp, loff_t *ppos)
 {
 	struct net_device *dev = ctl->extra1;
 	struct inet6_dev *idev;
@@ -1831,8 +1834,6 @@ int ndisc_ifinfo_sysctl_change(struct ctl_table *ctl, int write, void __user *bu
 	}
 	return ret;
 }
-
-
 #endif
 
 static int __net_init ndisc_net_init(struct net *net)
-- 
2.7.4

^ permalink raw reply related

* [PATCH net-next v1 2/2] net: ndisc.c: minor code improvement
From: yuan linyu @ 2017-05-26 13:48 UTC (permalink / raw)
  To: netdev; +Cc: David S . Miller, Joe Perches, David Ahern, yuan linyu

From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>

on x86_64, text size decrease 64 bytes

Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
---
 net/ipv6/ndisc.c | 34 ++++++++++++++++++----------------
 1 file changed, 18 insertions(+), 16 deletions(-)

diff --git a/net/ipv6/ndisc.c b/net/ipv6/ndisc.c
index 292c827..8051b46 100644
--- a/net/ipv6/ndisc.c
+++ b/net/ipv6/ndisc.c
@@ -147,17 +147,18 @@ void __ndisc_fill_addr_option(struct sk_buff *skb, int type, void *data,
 
 	opt[0] = type;
 	opt[1] = space >> 3;
+	opt   += 2;
+	space -= 2;
 
-	memset(opt + 2, 0, pad);
+	memset(opt, 0, pad);
 	opt   += pad;
 	space -= pad;
 
-	memcpy(opt + 2, data, data_len);
-	data_len += 2;
+	memcpy(opt, data, data_len);
 	opt += data_len;
 	space -= data_len;
-	if (space > 0)
-		memset(opt, 0, space);
+
+	memset(opt, 0, space);
 }
 EXPORT_SYMBOL_GPL(__ndisc_fill_addr_option);
 
@@ -997,6 +998,7 @@ static void ndisc_recv_na(struct sk_buff *skb)
 	if (neigh) {
 		u8 old_flags = neigh->flags;
 		struct net *net = dev_net(dev);
+		u32 flags;
 
 		if (neigh->nud_state & NUD_FAILED)
 			goto out;
@@ -1013,13 +1015,14 @@ static void ndisc_recv_na(struct sk_buff *skb)
 			goto out;
 		}
 
+		flags = NEIGH_UPDATE_F_WEAK_OVERRIDE | NEIGH_UPDATE_F_OVERRIDE_ISROUTER;
+		if (msg->icmph.icmp6_override)
+			flags |= NEIGH_UPDATE_F_OVERRIDE;
+		if (msg->icmph.icmp6_router)
+			flags |= NEIGH_UPDATE_F_ISROUTER;
 		ndisc_update(dev, neigh, lladdr,
 			     msg->icmph.icmp6_solicited ? NUD_REACHABLE : NUD_STALE,
-			     NEIGH_UPDATE_F_WEAK_OVERRIDE|
-			     (msg->icmph.icmp6_override ? NEIGH_UPDATE_F_OVERRIDE : 0)|
-			     NEIGH_UPDATE_F_OVERRIDE_ISROUTER|
-			     (msg->icmph.icmp6_router ? NEIGH_UPDATE_F_ISROUTER : 0),
-			     NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
+			     flags, NDISC_NEIGHBOUR_ADVERTISEMENT, &ndopts);
 
 		if ((old_flags & ~neigh->flags) & NTF_ROUTER) {
 			/*
@@ -1217,12 +1220,11 @@ static void ndisc_router_discovery(struct sk_buff *skb)
 	 * received RA message (RFC 2462) -- yoshfuji
 	 */
 	old_if_flags = in6_dev->if_flags;
-	in6_dev->if_flags = (in6_dev->if_flags & ~(IF_RA_MANAGED |
-				IF_RA_OTHERCONF)) |
-				(ra_msg->icmph.icmp6_addrconf_managed ?
-					IF_RA_MANAGED : 0) |
-				(ra_msg->icmph.icmp6_addrconf_other ?
-					IF_RA_OTHERCONF : 0);
+	in6_dev->if_flags &= ~(IF_RA_MANAGED | IF_RA_OTHERCONF);
+	if (ra_msg->icmph.icmp6_addrconf_managed)
+		in6_dev->if_flags |= IF_RA_MANAGED;
+	if (ra_msg->icmph.icmp6_addrconf_other)
+		in6_dev->if_flags |= IF_RA_OTHERCONF;
 
 	if (old_if_flags != in6_dev->if_flags)
 		send_ifinfo_notify = true;
-- 
2.7.4

^ permalink raw reply related

* Re: [PATCH net-next 1/2] net: ndisc.c: fix coding style issue
From: yuan linyu @ 2017-05-26 13:55 UTC (permalink / raw)
  To: 吉藤英明
  Cc: network dev, David S . Miller, Joe Perches, David Ahern,
	yuan linyu, YOSHIFUJI Hideaki
In-Reply-To: <CAPA1RqDqyZicNWM8arSvMfQjmy_A=LLEjtTwH8KTza4WwQ_dsg@mail.gmail.com>

On 五, 2017-05-26 at 22:45 +0900, 吉藤英明 wrote:
> Hi,
> 
> 2017-05-26 22:23 GMT+09:00 yuan linyu <cugyly@163.com>:
> > 
> > From: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> > 
> > Signed-off-by: yuan linyu <Linyu.Yuan@alcatel-sbell.com.cn>
> > ---
> >  net/ipv6/ndisc.c | 109 ++++++++++++++++++++++++++++---------------------------
> >  1 file changed, 55 insertions(+), 54 deletions(-)
> Sorry, I don't think this kind of change for style is good
> bacause this makes effort of  backport more difficult.
hi, i can't understand. 
if any change of this code you decide to backport, it need effort,
not only important fix.

do I miss your point ?
> 
> --yoshfuji
> 

^ permalink raw reply


This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox