nfp: calculate total port lanes for split
authorJakub Kicinski <jakub.kicinski@netronome.com>
Fri, 26 May 2017 08:03:35 +0000 (01:03 -0700)
committerDavid S. Miller <davem@davemloft.net>
Fri, 26 May 2017 15:01:49 +0000 (11:01 -0400)
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>
Signed-off-by: David S. Miller <davem@davemloft.net>
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp.h
drivers/net/ethernet/netronome/nfp/nfpcore/nfp_nsp_eth.c

index 36b21e4dc56d3fa8d48547b9f1ba1d3de5316d0f..84a1d20adae17ded010e57a9cba0ed547c71b27b 100644 (file)
@@ -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];
 };
index 639438d8313afc558d53233b6da7ab20c26417c0..b0f8785c064f1fc1af6cd765ef2e872687f7a5a5 100644 (file)
@@ -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]);