RE: [PATCH net-next 2/2] bnx2x: allocate mac filtering pending list in PAGE_SIZE increments

2016-09-20 Thread Mintz, Yuval
> >> Currently, we can have high order page allocations that specify
> >> GFP_ATOMIC when configuring multicast MAC address filters.
> >>
> >> For example, we have seen order 2 page allocation failures with
> >> ~500 multicast addresses configured.
> >>
> >> Convert the allocation for the pending list to be done in PAGE_SIZE
> >> increments.
> >>
> >> Signed-off-by: Jason Baron 
> >
> > While I appreciate the effort, I wonder whether it's worth it:
> >
> > - The hardware [even in its newer generation] provides an approximate
> > based classification [I.e., hashed] with 256 bins.
> > When configuring 500 multicast addresses, one can argue the difference
> > between multicast-promisc mode and actual configuration is
> > insignificant.
> 
> With 256 bins, I think it takes close to: 256*lg(256) or 2,048 multicast 
> addresses
> to expect to have all bins have at least one hash, assuming a uniform 
> distribution
> of the hashes.
> 
> > Perhaps the easier-to-maintain alternative would simply be to
> > determine the maximal number of multicast addresses that can be
> > configured using a single PAGE, and if in need of more than that
> > simply move into multicast-promisc.
> >
> 
> sizeof(struct bnx2x_mcast_list_elem) = 24. So there are 170 per page on x86. 
> So
> if we want to fit 2,048 elements, we need 12 pages.

That's not exactly what I mean - let's assume you'd have problems
allocating more than a PAGE. According to your calculation, that
means you're already using more than 170 multicast addresses.
I didn't bother trying to solve the combinatorics question of how
many bins you'd use on average for 170 filters given there are only
256 bins, but that would be a significant portion.
The question I rose was whether it actually makes a difference
under such circumstances whether the device would actually filter
those multicast addresses or be completely multicast promiscuous.
e.g., whether it's significant to be filtering out multicast ingress
traffic when you're already allowing 1/2 of all random multicast
packets to be classified for the interface.

But again, given that you've actually taken the trouble of solving
this, I guess this question is mostly theoretical. We HAVE a better
solution now [a.k.a., yours ;-) ]

> I think it would be easy to add a check to bnx2x_set_rx_mode_inner() to 
> enforce
> some maximum number of elements (perhaps 2,048 based on the above math)
> for the !CHIP_IS_E1() case on top of what I already posted.

The benefit should have been that we could have dropped your
Solution by limiting the driver to use at most the number of filters
that would fit in a single page.
I don't think it would serve any purpose to take your change and
in addition choose some combinatorics based upper limit.





[PATCH net-next] bnxt_en: Fix build error for kernesl without RTC-LIB

2016-09-20 Thread Michael Chan
From: Rob Swindell 

bnxt_hwrm_fw_set_time() now returns -EOPNOTSUPP when built for kernel
without RTC_LIB.  Setting the firmware time is not critical to the
successful completion of the firmware update process.

Signed-off-by: Rob Swindell 
Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index cbc0b8a..a9f9f37 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4323,6 +4323,7 @@ hwrm_ver_get_exit:
 
 int bnxt_hwrm_fw_set_time(struct bnxt *bp)
 {
+#if IS_ENABLED(CONFIG_RTC_LIB)
struct hwrm_fw_set_time_input req = {0};
struct rtc_time tm;
struct timeval tv;
@@ -4340,6 +4341,9 @@ int bnxt_hwrm_fw_set_time(struct bnxt *bp)
req.minute = tm.tm_min;
req.second = tm.tm_sec;
return hwrm_send_message(bp, , sizeof(req), HWRM_CMD_TIMEOUT);
+#else
+   return -EOPNOTSUPP;
+#endif
 }
 
 static int bnxt_hwrm_port_qstats(struct bnxt *bp)
-- 
1.8.3.1



Re: [v3] net: ipv6: fallback to full lookup if table lookup is unsuitable

2016-09-20 Thread David Miller
From: Vincent Bernat 
Date: Sun, 18 Sep 2016 17:46:07 +0200

> Commit 8c14586fc320 ("net: ipv6: Use passed in table for nexthop
> lookups") introduced a regression: insertion of an IPv6 route in a table
> not containing the appropriate connected route for the gateway but which
> contained a non-connected route (like a default gateway) fails while it
> was previously working:
> 
> $ ip link add eth0 type dummy
> $ ip link set up dev eth0
> $ ip addr add 2001:db8::1/64 dev eth0
> $ ip route add ::/0 via 2001:db8::5 dev eth0 table 20
> $ ip route add 2001:db8:cafe::1/128 via 2001:db8::6 dev eth0 table 20
> RTNETLINK answers: No route to host
> $ ip -6 route show table 20
> default via 2001:db8::5 dev eth0  metric 1024  pref medium
> 
> After this patch, we get:
> 
> $ ip route add 2001:db8:cafe::1/128 via 2001:db8::6 dev eth0 table 20
> $ ip -6 route show table 20
> 2001:db8:cafe::1 via 2001:db8::6 dev eth0  metric 1024  pref medium
> default via 2001:db8::5 dev eth0  metric 1024  pref medium
> 
> Fixes: 8c14586fc320 ("net: ipv6: Use passed in table for nexthop lookups")
> Signed-off-by: Vincent Bernat 

Applied and queued up for -stable, thanks.


Re: [PATCH net-next v2 00/10] bnxt: update for net-next.

2016-09-20 Thread David Miller
From: Michael Chan 
Date: Tue, 20 Sep 2016 02:50:18 -0400

> Misc. changes and minor bug fixes for net-next.  Please review.
> 
> v2: Updated "bnxt_en: Added support for Secure Firmware Update" patch.

Michael, I applied v1 already.


Re: [PATCH net-next 00/10] bnxt: update for net-next.

2016-09-20 Thread Michael Chan
On Mon, Sep 19, 2016 at 6:32 PM, David Miller  wrote:
> From: Michael Chan 
> Date: Mon, 19 Sep 2016 03:57:59 -0400
>
>> Misc. changes and minor bug fixes for net-next.  Please review.
>
> Series applied, thanks Michael.

Sorry, I missed this and sent out v2.  Please ignore v2 and I will
send a small patch to fix up the kbuild_test_rebot error.  Thanks.


[PATCH net-next v2 06/10] bnxt_en: Re-arrange bnxt_hwrm_func_qcaps().

2016-09-20 Thread Michael Chan
Re-arrange the code so that the generation of the random MAC address for
the VF is at the end of the function.  The next patch will add one more step
to call bnxt_approve_mac() to get the firmware to approve the random MAC
address.

Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 23 ---
 1 file changed, 12 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 088b922..dc2559a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4161,6 +4161,11 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
if (rc)
goto hwrm_func_qcaps_exit;
 
+   bp->tx_push_thresh = 0;
+   if (resp->flags &
+   cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED))
+   bp->tx_push_thresh = BNXT_TX_PUSH_THRESH;
+
if (BNXT_PF(bp)) {
struct bnxt_pf_info *pf = >pf;
 
@@ -4192,12 +4197,6 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
struct bnxt_vf_info *vf = >vf;
 
vf->fw_fid = le16_to_cpu(resp->fid);
-   memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN);
-   if (is_valid_ether_addr(vf->mac_addr))
-   /* overwrite netdev dev_adr with admin VF MAC */
-   memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
-   else
-   random_ether_addr(bp->dev->dev_addr);
 
vf->max_rsscos_ctxs = le16_to_cpu(resp->max_rsscos_ctx);
vf->max_cp_rings = le16_to_cpu(resp->max_cmpl_rings);
@@ -4209,14 +4208,16 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
vf->max_l2_ctxs = le16_to_cpu(resp->max_l2_ctxs);
vf->max_vnics = le16_to_cpu(resp->max_vnics);
vf->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx);
+
+   memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN);
+   if (is_valid_ether_addr(vf->mac_addr))
+   /* overwrite netdev dev_adr with admin VF MAC */
+   memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
+   else
+   random_ether_addr(bp->dev->dev_addr);
 #endif
}
 
-   bp->tx_push_thresh = 0;
-   if (resp->flags &
-   cpu_to_le32(FUNC_QCAPS_RESP_FLAGS_PUSH_MODE_SUPPORTED))
-   bp->tx_push_thresh = BNXT_TX_PUSH_THRESH;
-
 hwrm_func_qcaps_exit:
mutex_unlock(>hwrm_cmd_lock);
return rc;
-- 
1.8.3.1



[PATCH net-next v2 07/10] bnxt_en: Call firmware to approve the random VF MAC address.

2016-09-20 Thread Michael Chan
After generating the random MAC address for VF, call the firmware to
approve it.  This step serves 2 purposes.  Some hypervisor (e.g. ESX)
wants to approve the MAC address.  2nd, the call will setup the
proper forwarding database in the internal switch.

We need to unlock the hwrm_cmd_lock mutex before calling bnxt_approve_mac().
We can do that because we are at the end of the function and all the
previous firmware response data has been copied.

Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 9 +++--
 1 file changed, 7 insertions(+), 2 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index dc2559a..a9f9f37 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4210,11 +4210,16 @@ int bnxt_hwrm_func_qcaps(struct bnxt *bp)
vf->max_stat_ctxs = le16_to_cpu(resp->max_stat_ctx);
 
memcpy(vf->mac_addr, resp->mac_address, ETH_ALEN);
-   if (is_valid_ether_addr(vf->mac_addr))
+   mutex_unlock(>hwrm_cmd_lock);
+
+   if (is_valid_ether_addr(vf->mac_addr)) {
/* overwrite netdev dev_adr with admin VF MAC */
memcpy(bp->dev->dev_addr, vf->mac_addr, ETH_ALEN);
-   else
+   } else {
random_ether_addr(bp->dev->dev_addr);
+   rc = bnxt_approve_mac(bp, bp->dev->dev_addr);
+   }
+   return rc;
 #endif
}
 
-- 
1.8.3.1



[PATCH net-next v2 05/10] bnxt_en: Fix ethtool -l|-L inconsistent channel counts.

2016-09-20 Thread Michael Chan
The existing code is inconsistent in reporting and accepting the combined
channel count.  bnxt_get_channels() reports maximum combined as the
maximum rx count.  bnxt_set_channels() accepts combined count that
cannot be bigger than max rx or max tx.

For example, if max rx = 2 and max tx = 1, we report max supported
combined to be 2.  But if the user tries to set combined to 2, it will
fail because 2 is bigger than max tx which is 1.

Fix the code to be consistent.  Max allowed combined = max(max_rx, max_tx).
We will accept a combined channel count <= max(max_rx, max_tx).

Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 12 +++-
 1 file changed, 7 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index ae4458d..de893c9 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -348,7 +348,7 @@ static void bnxt_get_channels(struct net_device *dev,
int max_rx_rings, max_tx_rings, tcs;
 
bnxt_get_max_rings(bp, _rx_rings, _tx_rings, true);
-   channel->max_combined = max_rx_rings;
+   channel->max_combined = max_t(int, max_rx_rings, max_tx_rings);
 
if (bnxt_get_max_rings(bp, _rx_rings, _tx_rings, false)) {
max_rx_rings = 0;
@@ -406,8 +406,8 @@ static int bnxt_set_channels(struct net_device *dev,
if (tcs > 1)
max_tx_rings /= tcs;
 
-   if (sh && (channel->combined_count > max_rx_rings ||
-  channel->combined_count > max_tx_rings))
+   if (sh &&
+   channel->combined_count > max_t(int, max_rx_rings, max_tx_rings))
return -ENOMEM;
 
if (!sh && (channel->rx_count > max_rx_rings ||
@@ -430,8 +430,10 @@ static int bnxt_set_channels(struct net_device *dev,
 
if (sh) {
bp->flags |= BNXT_FLAG_SHARED_RINGS;
-   bp->rx_nr_rings = channel->combined_count;
-   bp->tx_nr_rings_per_tc = channel->combined_count;
+   bp->rx_nr_rings = min_t(int, channel->combined_count,
+   max_rx_rings);
+   bp->tx_nr_rings_per_tc = min_t(int, channel->combined_count,
+  max_tx_rings);
} else {
bp->flags &= ~BNXT_FLAG_SHARED_RINGS;
bp->rx_nr_rings = channel->rx_count;
-- 
1.8.3.1



[PATCH net-next v2 09/10] bnxt_en: Support for "ethtool -r" command

2016-09-20 Thread Michael Chan
From: Deepak Khungar 

Restart autoneg if autoneg is enabled.

Signed-off-by: Deepak Khungar 
Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 20 
 1 file changed, 20 insertions(+)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index de893c9..0ee4d7b 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -1849,6 +1849,25 @@ static int bnxt_get_module_eeprom(struct net_device *dev,
return rc;
 }
 
+static int bnxt_nway_reset(struct net_device *dev)
+{
+   int rc = 0;
+
+   struct bnxt *bp = netdev_priv(dev);
+   struct bnxt_link_info *link_info = >link_info;
+
+   if (!BNXT_SINGLE_PF(bp))
+   return -EOPNOTSUPP;
+
+   if (!(link_info->autoneg & BNXT_AUTONEG_SPEED))
+   return -EINVAL;
+
+   if (netif_running(dev))
+   rc = bnxt_hwrm_set_link_setting(bp, true, false);
+
+   return rc;
+}
+
 const struct ethtool_ops bnxt_ethtool_ops = {
.get_link_ksettings = bnxt_get_link_ksettings,
.set_link_ksettings = bnxt_set_link_ksettings,
@@ -1881,4 +1900,5 @@ const struct ethtool_ops bnxt_ethtool_ops = {
.set_eee= bnxt_set_eee,
.get_module_info= bnxt_get_module_info,
.get_module_eeprom  = bnxt_get_module_eeprom,
+   .nway_reset = bnxt_nway_reset
 };
-- 
1.8.3.1



[PATCH net-next v2 10/10] bnxt_en: Fixed the VF link status after a link state change

2016-09-20 Thread Michael Chan
From: Eddie Wai 

The VF link state can be changed via the 'ip link set' cmd.
Currently, the new link state does not take effect immediately.

The fix is for the PF to send a link change async event to the
designated VF after a VF link state change.  This async event will
trigger the VF to update the link status.

Signed-off-by: Eddie Wai 
Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c | 84 -
 1 file changed, 42 insertions(+), 42 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
index 50d2007..8be7185 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c
@@ -19,6 +19,45 @@
 #include "bnxt_ethtool.h"
 
 #ifdef CONFIG_BNXT_SRIOV
+static int bnxt_hwrm_fwd_async_event_cmpl(struct bnxt *bp,
+ struct bnxt_vf_info *vf, u16 event_id)
+{
+   struct hwrm_fwd_async_event_cmpl_output *resp = bp->hwrm_cmd_resp_addr;
+   struct hwrm_fwd_async_event_cmpl_input req = {0};
+   struct hwrm_async_event_cmpl *async_cmpl;
+   int rc = 0;
+
+   bnxt_hwrm_cmd_hdr_init(bp, , HWRM_FWD_ASYNC_EVENT_CMPL, -1, -1);
+   if (vf)
+   req.encap_async_event_target_id = cpu_to_le16(vf->fw_fid);
+   else
+   /* broadcast this async event to all VFs */
+   req.encap_async_event_target_id = cpu_to_le16(0x);
+   async_cmpl = (struct hwrm_async_event_cmpl *)req.encap_async_event_cmpl;
+   async_cmpl->type =
+   cpu_to_le16(HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT);
+   async_cmpl->event_id = cpu_to_le16(event_id);
+
+   mutex_lock(>hwrm_cmd_lock);
+   rc = _hwrm_send_message(bp, , sizeof(req), HWRM_CMD_TIMEOUT);
+
+   if (rc) {
+   netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl failed. rc:%d\n",
+  rc);
+   goto fwd_async_event_cmpl_exit;
+   }
+
+   if (resp->error_code) {
+   netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl error %d\n",
+  resp->error_code);
+   rc = -1;
+   }
+
+fwd_async_event_cmpl_exit:
+   mutex_unlock(>hwrm_cmd_lock);
+   return rc;
+}
+
 static int bnxt_vf_ndo_prep(struct bnxt *bp, int vf_id)
 {
if (!test_bit(BNXT_STATE_OPEN, >state)) {
@@ -243,8 +282,9 @@ int bnxt_set_vf_link_state(struct net_device *dev, int 
vf_id, int link)
rc = -EINVAL;
break;
}
-   /* CHIMP TODO: send msg to VF to update new link state */
-
+   if (vf->flags & (BNXT_VF_LINK_UP | BNXT_VF_LINK_FORCED))
+   rc = bnxt_hwrm_fwd_async_event_cmpl(bp, vf,
+   HWRM_ASYNC_EVENT_CMPL_EVENT_ID_LINK_STATUS_CHANGE);
return rc;
 }
 
@@ -525,46 +565,6 @@ err_out1:
return rc;
 }
 
-static int bnxt_hwrm_fwd_async_event_cmpl(struct bnxt *bp,
- struct bnxt_vf_info *vf,
- u16 event_id)
-{
-   int rc = 0;
-   struct hwrm_fwd_async_event_cmpl_input req = {0};
-   struct hwrm_fwd_async_event_cmpl_output *resp = bp->hwrm_cmd_resp_addr;
-   struct hwrm_async_event_cmpl *async_cmpl;
-
-   bnxt_hwrm_cmd_hdr_init(bp, , HWRM_FWD_ASYNC_EVENT_CMPL, -1, -1);
-   if (vf)
-   req.encap_async_event_target_id = cpu_to_le16(vf->fw_fid);
-   else
-   /* broadcast this async event to all VFs */
-   req.encap_async_event_target_id = cpu_to_le16(0x);
-   async_cmpl = (struct hwrm_async_event_cmpl *)req.encap_async_event_cmpl;
-   async_cmpl->type =
-   cpu_to_le16(HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT);
-   async_cmpl->event_id = cpu_to_le16(event_id);
-
-   mutex_lock(>hwrm_cmd_lock);
-   rc = _hwrm_send_message(bp, , sizeof(req), HWRM_CMD_TIMEOUT);
-
-   if (rc) {
-   netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl failed. rc:%d\n",
-  rc);
-   goto fwd_async_event_cmpl_exit;
-   }
-
-   if (resp->error_code) {
-   netdev_err(bp->dev, "hwrm_fwd_async_event_cmpl error %d\n",
-  resp->error_code);
-   rc = -1;
-   }
-
-fwd_async_event_cmpl_exit:
-   mutex_unlock(>hwrm_cmd_lock);
-   return rc;
-}
-
 void bnxt_sriov_disable(struct bnxt *bp)
 {
u16 num_vfs = pci_num_vf(bp->pdev);
-- 
1.8.3.1



[PATCH net-next v2 04/10] bnxt_en: Added support for Secure Firmware Update

2016-09-20 Thread Michael Chan
From: Rob Swindell 

Using Ethtool flashdev command, entire NVM package (*.pkg) files
may now be staged into the "update" area of the NVM and subsequently
verified and installed by the firmware using the newly introduced
command: NVM_INSTALL_UPDATE.

We also introduce use of the new firmware command FW_SET_TIME so that the
NVM-resident package installation log contains valid time-stamps.

v2: Fixed undefined rtc_time64_to_tm error on kernels that don't have
CONFIG_RTC_LIB.  The timestamp is optional, so don't provide it if not
available.  Use '!' instead of '== 0'.

Signed-off-by: Rob Swindell 
Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c |  28 
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |   1 +
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c | 155 --
 drivers/net/ethernet/broadcom/bnxt/bnxt_fw_hdr.h  |  16 ++-
 4 files changed, 186 insertions(+), 14 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index f6b4f34..088b922 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -32,6 +32,7 @@
 #include 
 #include 
 #include 
+#include 
 #include 
 #include 
 #include 
@@ -4314,6 +4315,31 @@ hwrm_ver_get_exit:
return rc;
 }
 
+int bnxt_hwrm_fw_set_time(struct bnxt *bp)
+{
+#if IS_ENABLED(CONFIG_RTC_LIB)
+   struct hwrm_fw_set_time_input req = {0};
+   struct rtc_time tm;
+   struct timeval tv;
+
+   if (bp->hwrm_spec_code < 0x10400)
+   return -EOPNOTSUPP;
+
+   do_gettimeofday();
+   rtc_time_to_tm(tv.tv_sec, );
+   bnxt_hwrm_cmd_hdr_init(bp, , HWRM_FW_SET_TIME, -1, -1);
+   req.year = cpu_to_le16(1900 + tm.tm_year);
+   req.month = 1 + tm.tm_mon;
+   req.day = tm.tm_mday;
+   req.hour = tm.tm_hour;
+   req.minute = tm.tm_min;
+   req.second = tm.tm_sec;
+   return hwrm_send_message(bp, , sizeof(req), HWRM_CMD_TIMEOUT);
+#else
+   return -EOPNOTSUPP;
+#endif
+}
+
 static int bnxt_hwrm_port_qstats(struct bnxt *bp)
 {
int rc;
@@ -6811,6 +6837,8 @@ static int bnxt_init_one(struct pci_dev *pdev, const 
struct pci_device_id *ent)
if (rc)
goto init_err;
 
+   bnxt_hwrm_fw_set_time(bp);
+
dev->hw_features = NETIF_F_IP_CSUM | NETIF_F_IPV6_CSUM | NETIF_F_SG |
   NETIF_F_TSO | NETIF_F_TSO6 |
   NETIF_F_GSO_UDP_TUNNEL | NETIF_F_GSO_GRE |
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 012cc51..41033d0 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -1220,6 +1220,7 @@ int bnxt_hwrm_set_coal(struct bnxt *);
 int bnxt_hwrm_func_qcaps(struct bnxt *);
 int bnxt_hwrm_set_pause(struct bnxt *);
 int bnxt_hwrm_set_link_setting(struct bnxt *, bool, bool);
+int bnxt_hwrm_fw_set_time(struct bnxt *);
 int bnxt_open_nic(struct bnxt *, bool, bool);
 int bnxt_close_nic(struct bnxt *, bool, bool);
 int bnxt_get_max_rings(struct bnxt *, int *, int *, bool);
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
index b83e174..ae4458d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c
@@ -21,6 +21,8 @@
 #include "bnxt_nvm_defs.h" /* NVRAM content constant and structure defs */
 #include "bnxt_fw_hdr.h"   /* Firmware hdr constant and structure defs */
 #define FLASH_NVRAM_TIMEOUT((HWRM_CMD_TIMEOUT) * 100)
+#define FLASH_PACKAGE_TIMEOUT  ((HWRM_CMD_TIMEOUT) * 200)
+#define INSTALL_PACKAGE_TIMEOUT((HWRM_CMD_TIMEOUT) * 200)
 
 static char *bnxt_get_pkgver(struct net_device *dev, char *buf, size_t buflen);
 
@@ -1028,6 +1030,10 @@ static u32 bnxt_get_link(struct net_device *dev)
return bp->link_info.link_up;
 }
 
+static int bnxt_find_nvram_item(struct net_device *dev, u16 type, u16 ordinal,
+   u16 ext, u16 *index, u32 *item_length,
+   u32 *data_length);
+
 static int bnxt_flash_nvram(struct net_device *dev,
u16 dir_type,
u16 dir_ordinal,
@@ -1179,7 +1185,6 @@ static int bnxt_flash_firmware(struct net_device *dev,
   (unsigned long)calculated_crc);
return -EINVAL;
}
-   /* TODO: Validate digital signature (RSA-encrypted SHA-256 hash) here */
rc = bnxt_flash_nvram(dev, dir_type, BNX_DIR_ORDINAL_FIRST,
  0, 0, fw_data, fw_size);
if (rc == 0)/* Firmware update successful */
@@ -1188,6 +1193,57 @@ static int bnxt_flash_firmware(struct net_device *dev,
return rc;
 }
 
+static int bnxt_flash_microcode(struct net_device *dev,
+   

[PATCH net-next v2 03/10] bnxt_en: Update to firmware interface spec 1.5.1.

2016-09-20 Thread Michael Chan
Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c |3 +
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |   14 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 1251 +++--
 3 files changed, 760 insertions(+), 508 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index d9b4cd1..f6b4f34 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -4253,6 +4253,9 @@ static int bnxt_hwrm_queue_qportcfg(struct bnxt *bp)
if (bp->max_tc > BNXT_MAX_QUEUE)
bp->max_tc = BNXT_MAX_QUEUE;
 
+   if (resp->queue_cfg_info & QUEUE_QPORTCFG_RESP_QUEUE_CFG_INFO_ASYM_CFG)
+   bp->max_tc = 1;
+
qptr = >queue_id0;
for (i = 0; i < bp->max_tc; i++) {
bp->q_info[i].queue_id = *qptr++;
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index db4814e..012cc51 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -11,10 +11,10 @@
 #define BNXT_H
 
 #define DRV_MODULE_NAME"bnxt_en"
-#define DRV_MODULE_VERSION "1.3.0"
+#define DRV_MODULE_VERSION "1.5.0"
 
 #define DRV_VER_MAJ1
-#define DRV_VER_MIN3
+#define DRV_VER_MIN5
 #define DRV_VER_UPD0
 
 struct tx_bd {
@@ -106,11 +106,11 @@ struct tx_cmp {
 #define CMP_TYPE_REMOTE_DRIVER_REQ  34
 #define CMP_TYPE_REMOTE_DRIVER_RESP 36
 #define CMP_TYPE_ERROR_STATUS   48
-#define CMPL_BASE_TYPE_STAT_EJECT   (0x1aUL << 0)
-#define CMPL_BASE_TYPE_HWRM_DONE(0x20UL << 0)
-#define CMPL_BASE_TYPE_HWRM_FWD_REQ (0x22UL << 0)
-#define CMPL_BASE_TYPE_HWRM_FWD_RESP(0x24UL << 0)
-#define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT (0x2eUL << 0)
+#define CMPL_BASE_TYPE_STAT_EJECT   0x1aUL
+#define CMPL_BASE_TYPE_HWRM_DONE0x20UL
+#define CMPL_BASE_TYPE_HWRM_FWD_REQ 0x22UL
+#define CMPL_BASE_TYPE_HWRM_FWD_RESP0x24UL
+#define CMPL_BASE_TYPE_HWRM_ASYNC_EVENT 0x2eUL
 
#define TX_CMP_FLAGS_ERROR  (1 << 6)
#define TX_CMP_FLAGS_PUSH   (1 << 7)
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h
index 517567f..04a96cc 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h
@@ -39,7 +39,7 @@ struct eject_cmpl {
__le16 type;
#define EJECT_CMPL_TYPE_MASK0x3fUL
#define EJECT_CMPL_TYPE_SFT 0
-   #define EJECT_CMPL_TYPE_STAT_EJECT (0x1aUL << 0)
+   #define EJECT_CMPL_TYPE_STAT_EJECT 0x1aUL
__le16 len;
__le32 opaque;
__le32 v;
@@ -52,7 +52,7 @@ struct hwrm_cmpl {
__le16 type;
#define HWRM_CMPL_TYPE_MASK 0x3fUL
#define HWRM_CMPL_TYPE_SFT  0
-   #define HWRM_CMPL_TYPE_HWRM_DONE   (0x20UL << 0)
+   #define HWRM_CMPL_TYPE_HWRM_DONE   0x20UL
__le16 sequence_id;
__le32 unused_1;
__le32 v;
@@ -65,7 +65,7 @@ struct hwrm_fwd_req_cmpl {
__le16 req_len_type;
#define HWRM_FWD_REQ_CMPL_TYPE_MASK 0x3fUL
#define HWRM_FWD_REQ_CMPL_TYPE_SFT  0
-   #define HWRM_FWD_REQ_CMPL_TYPE_HWRM_FWD_REQ(0x22UL << 0)
+   #define HWRM_FWD_REQ_CMPL_TYPE_HWRM_FWD_REQ0x22UL
#define HWRM_FWD_REQ_CMPL_REQ_LEN_MASK  0xffc0UL
#define HWRM_FWD_REQ_CMPL_REQ_LEN_SFT   6
__le16 source_id;
@@ -81,7 +81,7 @@ struct hwrm_fwd_resp_cmpl {
__le16 type;
#define HWRM_FWD_RESP_CMPL_TYPE_MASK0x3fUL
#define HWRM_FWD_RESP_CMPL_TYPE_SFT 0
-   #define HWRM_FWD_RESP_CMPL_TYPE_HWRM_FWD_RESP  (0x24UL << 0)
+   #define HWRM_FWD_RESP_CMPL_TYPE_HWRM_FWD_RESP  0x24UL
__le16 source_id;
__le16 resp_len;
__le16 unused_1;
@@ -96,25 +96,26 @@ struct hwrm_async_event_cmpl {
__le16 type;
#define HWRM_ASYNC_EVENT_CMPL_TYPE_MASK 0x3fUL
#define HWRM_ASYNC_EVENT_CMPL_TYPE_SFT  0
-   #define HWRM_ASYNC_EVENT_CMPL_TYPE_HWRM_ASYNC_EVENT   (0x2eUL << 0)
+   #define 

[PATCH net-next v2 08/10] bnxt_en: Pad TX packets below 52 bytes.

2016-09-20 Thread Michael Chan
The hardware has a limitation that it won't pass host to BMC loopback
packets below 52-bytes.

Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.h | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 41033d0..51b164a 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -413,7 +413,7 @@ struct rx_tpa_end_cmp_ext {
 
 #define BNXT_RX_PAGE_SIZE (1 << BNXT_RX_PAGE_SHIFT)
 
-#define BNXT_MIN_PKT_SIZE  45
+#define BNXT_MIN_PKT_SIZE  52
 
 #define BNXT_NUM_TESTS(bp) 0
 
-- 
1.8.3.1



[PATCH net-next v2 00/10] bnxt: update for net-next.

2016-09-20 Thread Michael Chan
Misc. changes and minor bug fixes for net-next.  Please review.

v2: Updated "bnxt_en: Added support for Secure Firmware Update" patch.

Deepak Khungar (1):
  bnxt_en: Support for "ethtool -r" command

Eddie Wai (1):
  bnxt_en: Fixed the VF link status after a link state change

Michael Chan (7):
  bnxt_en: Use RSS flags defined in the bnxt_hsi.h file.
  bnxt_en: Simplify PCI device names and add additinal PCI IDs.
  bnxt_en: Update to firmware interface spec 1.5.1.
  bnxt_en: Fix ethtool -l|-L inconsistent channel counts.
  bnxt_en: Re-arrange bnxt_hwrm_func_qcaps().
  bnxt_en: Call firmware to approve the random VF MAC address.
  bnxt_en: Pad TX packets below 52 bytes.

Rob Swindell (1):
  bnxt_en: Added support for Secure Firmware Update

 drivers/net/ethernet/broadcom/bnxt/bnxt.c |  135 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt.h |   22 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_ethtool.c |  187 ++-
 drivers/net/ethernet/broadcom/bnxt/bnxt_fw_hdr.h  |   16 +-
 drivers/net/ethernet/broadcom/bnxt/bnxt_hsi.h | 1251 -
 drivers/net/ethernet/broadcom/bnxt/bnxt_sriov.c   |   84 +-
 6 files changed, 1073 insertions(+), 622 deletions(-)

-- 
1.8.3.1



[PATCH net-next v2 01/10] bnxt_en: Use RSS flags defined in the bnxt_hsi.h file.

2016-09-20 Thread Michael Chan
And remove redundant definitions of the same flags.

Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 8 
 drivers/net/ethernet/broadcom/bnxt/bnxt.h | 5 -
 2 files changed, 4 insertions(+), 9 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index 228c964..cee0e8d 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -3419,10 +3419,10 @@ static int bnxt_hwrm_vnic_set_rss(struct bnxt *bp, u16 
vnic_id, bool set_rss)
 
bnxt_hwrm_cmd_hdr_init(bp, , HWRM_VNIC_RSS_CFG, -1, -1);
if (set_rss) {
-   vnic->hash_type = BNXT_RSS_HASH_TYPE_FLAG_IPV4 |
-BNXT_RSS_HASH_TYPE_FLAG_TCP_IPV4 |
-BNXT_RSS_HASH_TYPE_FLAG_IPV6 |
-BNXT_RSS_HASH_TYPE_FLAG_TCP_IPV6;
+   vnic->hash_type = VNIC_RSS_CFG_REQ_HASH_TYPE_IPV4 |
+ VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV4 |
+ VNIC_RSS_CFG_REQ_HASH_TYPE_IPV6 |
+ VNIC_RSS_CFG_REQ_HASH_TYPE_TCP_IPV6;
 
req.hash_type = cpu_to_le32(vnic->hash_type);
 
diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.h 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
index 23e04a6..db4814e 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.h
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.h
@@ -389,11 +389,6 @@ struct rx_tpa_end_cmp_ext {
 
 #define INVALID_HW_RING_ID ((u16)-1)
 
-#define BNXT_RSS_HASH_TYPE_FLAG_IPV4   0x01
-#define BNXT_RSS_HASH_TYPE_FLAG_TCP_IPV4   0x02
-#define BNXT_RSS_HASH_TYPE_FLAG_IPV6   0x04
-#define BNXT_RSS_HASH_TYPE_FLAG_TCP_IPV6   0x08
-
 /* The hardware supports certain page sizes.  Use the supported page sizes
  * to allocate the rings.
  */
-- 
1.8.3.1



[PATCH net-next v2 02/10] bnxt_en: Simplify PCI device names and add additinal PCI IDs.

2016-09-20 Thread Michael Chan
Remove "Single-port/Dual-port" from the device names.  Dual-port devices
will appear as 2 separate devices, so no need to call each a dual-port
device.  Use a more generic name for VF devices belonging to the same
chip fanmily.  Add some remaining NPAR device IDs.

Signed-off-by: David Christensen 
Signed-off-by: Michael Chan 
---
 drivers/net/ethernet/broadcom/bnxt/bnxt.c | 68 ---
 1 file changed, 36 insertions(+), 32 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/bnxt/bnxt.c 
b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
index cee0e8d..d9b4cd1 100644
--- a/drivers/net/ethernet/broadcom/bnxt/bnxt.c
+++ b/drivers/net/ethernet/broadcom/bnxt/bnxt.c
@@ -93,50 +93,49 @@ enum board_idx {
BCM57404_NPAR,
BCM57406_NPAR,
BCM57407_SFP,
+   BCM57407_NPAR,
BCM57414_NPAR,
BCM57416_NPAR,
-   BCM57304_VF,
-   BCM57404_VF,
-   BCM57414_VF,
-   BCM57314_VF,
+   NETXTREME_E_VF,
+   NETXTREME_C_VF,
 };
 
 /* indexed by enum above */
 static const struct {
char *name;
 } board_info[] = {
-   { "Broadcom BCM57301 NetXtreme-C Single-port 10Gb Ethernet" },
-   { "Broadcom BCM57302 NetXtreme-C Dual-port 10Gb/25Gb Ethernet" },
-   { "Broadcom BCM57304 NetXtreme-C Dual-port 10Gb/25Gb/40Gb/50Gb 
Ethernet" },
+   { "Broadcom BCM57301 NetXtreme-C 10Gb Ethernet" },
+   { "Broadcom BCM57302 NetXtreme-C 10Gb/25Gb Ethernet" },
+   { "Broadcom BCM57304 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
{ "Broadcom BCM57417 NetXtreme-E Ethernet Partition" },
-   { "Broadcom BCM58700 Nitro 4-port 1Gb/2.5Gb/10Gb Ethernet" },
-   { "Broadcom BCM57311 NetXtreme-C Single-port 10Gb Ethernet" },
-   { "Broadcom BCM57312 NetXtreme-C Dual-port 10Gb/25Gb Ethernet" },
-   { "Broadcom BCM57402 NetXtreme-E Dual-port 10Gb Ethernet" },
-   { "Broadcom BCM57404 NetXtreme-E Dual-port 10Gb/25Gb Ethernet" },
-   { "Broadcom BCM57406 NetXtreme-E Dual-port 10GBase-T Ethernet" },
+   { "Broadcom BCM58700 Nitro 1Gb/2.5Gb/10Gb Ethernet" },
+   { "Broadcom BCM57311 NetXtreme-C 10Gb Ethernet" },
+   { "Broadcom BCM57312 NetXtreme-C 10Gb/25Gb Ethernet" },
+   { "Broadcom BCM57402 NetXtreme-E 10Gb Ethernet" },
+   { "Broadcom BCM57404 NetXtreme-E 10Gb/25Gb Ethernet" },
+   { "Broadcom BCM57406 NetXtreme-E 10GBase-T Ethernet" },
{ "Broadcom BCM57402 NetXtreme-E Ethernet Partition" },
-   { "Broadcom BCM57407 NetXtreme-E Dual-port 10GBase-T Ethernet" },
-   { "Broadcom BCM57412 NetXtreme-E Dual-port 10Gb Ethernet" },
-   { "Broadcom BCM57414 NetXtreme-E Dual-port 10Gb/25Gb Ethernet" },
-   { "Broadcom BCM57416 NetXtreme-E Dual-port 10GBase-T Ethernet" },
-   { "Broadcom BCM57417 NetXtreme-E Dual-port 10GBase-T Ethernet" },
+   { "Broadcom BCM57407 NetXtreme-E 10GBase-T Ethernet" },
+   { "Broadcom BCM57412 NetXtreme-E 10Gb Ethernet" },
+   { "Broadcom BCM57414 NetXtreme-E 10Gb/25Gb Ethernet" },
+   { "Broadcom BCM57416 NetXtreme-E 10GBase-T Ethernet" },
+   { "Broadcom BCM57417 NetXtreme-E 10GBase-T Ethernet" },
{ "Broadcom BCM57412 NetXtreme-E Ethernet Partition" },
-   { "Broadcom BCM57314 NetXtreme-C Dual-port 10Gb/25Gb/40Gb/50Gb 
Ethernet" },
-   { "Broadcom BCM57417 NetXtreme-E Dual-port 10Gb/25Gb Ethernet" },
-   { "Broadcom BCM57416 NetXtreme-E Dual-port 10Gb Ethernet" },
+   { "Broadcom BCM57314 NetXtreme-C 10Gb/25Gb/40Gb/50Gb Ethernet" },
+   { "Broadcom BCM57417 NetXtreme-E 10Gb/25Gb Ethernet" },
+   { "Broadcom BCM57416 NetXtreme-E 10Gb Ethernet" },
{ "Broadcom BCM57404 NetXtreme-E Ethernet Partition" },
{ "Broadcom BCM57406 NetXtreme-E Ethernet Partition" },
-   { "Broadcom BCM57407 NetXtreme-E Dual-port 25Gb Ethernet" },
+   { "Broadcom BCM57407 NetXtreme-E 25Gb Ethernet" },
+   { "Broadcom BCM57407 NetXtreme-E Ethernet Partition" },
{ "Broadcom BCM57414 NetXtreme-E Ethernet Partition" },
{ "Broadcom BCM57416 NetXtreme-E Ethernet Partition" },
-   { "Broadcom BCM57304 NetXtreme-C Ethernet Virtual Function" },
-   { "Broadcom BCM57404 NetXtreme-E Ethernet Virtual Function" },
-   { "Broadcom BCM57414 NetXtreme-E Ethernet Virtual Function" },
-   { "Broadcom BCM57314 NetXtreme-E Ethernet Virtual Function" },
+   { "Broadcom NetXtreme-E Ethernet Virtual Function" },
+   { "Broadcom NetXtreme-C Ethernet Virtual Function" },
 };
 
 static const struct pci_device_id bnxt_pci_tbl[] = {
+   { PCI_VDEVICE(BROADCOM, 0x16c0), .driver_data = BCM57417_NPAR },
{ PCI_VDEVICE(BROADCOM, 0x16c8), .driver_data = BCM57301 },
{ PCI_VDEVICE(BROADCOM, 0x16c9), .driver_data = BCM57302 },
{ PCI_VDEVICE(BROADCOM, 0x16ca), .driver_data = BCM57304 },
@@ -160,13 +159,19 @@ static const struct pci_device_id bnxt_pci_tbl[] = {
{ PCI_VDEVICE(BROADCOM, 0x16e7), 

Re: [net-next PATCH] net: netlink messages for HW addr programming

2016-09-20 Thread Roopa Prabhu
On 9/19/16, 10:49 PM, Jiri Pirko wrote:
> Tue, Sep 20, 2016 at 07:31:27AM CEST, ro...@cumulusnetworks.com wrote:
>> On 9/19/16, 7:46 AM, Patrick Ruddy wrote:
>>> On Sun, 2016-09-18 at 07:51 -0700, Roopa Prabhu wrote:
 On 9/15/16, 9:48 AM, Patrick Ruddy wrote:
> Add RTM_NEWADDR and RTM_DELADDR netlink messages with family
> AF_UNSPEC to indicate interest in specific unicast and multicast
> hardware addresses. These messages are sent when addresses are
> added or deleted from the appropriate interface driver.
> Added AF_UNSPEC GETADDR function to allow the netlink notifications
> to be replayed to avoid loss of state due to application start
> ordering or restart.
>
> Signed-off-by: Patrick Ruddy 
> ---
 RTM_NEWADDR and RTM_DELADDR are not used to add these entries to the 
 kernel.
 so, it seems a bit wrong to use RTM_NEWADDR and RTM_DELADDR to notify them 
 to
 userspace and also to request a special dump of these addresses.

 This could just be a new nested netlink attribute in the existing link 
 dump ?
>>> Hi Roopa
>>>
>>> Thanks for the review. I did initially code this using NEW/DEL/GET_LINK
>>> messages but was asked to change to to ADDR messages by Stephen
>>> Hemminger (cc'd). 
>>>
>>> However I agree that these addresses fall between the LINK and ADDR
>>> areas so I'm happy to change this if we can reach some consensus on the
>>> format.
>>>
>> ok, thanks for the history. yes, they do lie in a weird spot.
> They are l2 addresses, they should be threated accordingly. Am I missing
> something?
>
>
>> the general convention for other rtnl registrations seems to be
>> AF_UNSPEC family means include all supported families. thats where this 
>> seems a bit odd.
>>
>> On the other hand, one reason I see where using RTM_*ADDR will be useful for 
>> this is if we wanted
>> to provide a way to add these uc and mc address via ip addr add in the 
>> future.
>> ip addr add  dev eth0
>>
>> Does this patch allow that in the future ?
> This shoul go under ip link I believe. "ip addr" is for l3.
>
>
yes, ...my initial comment was the same (two new attributes to cover UC and MC 
addresses).
patrick had it in link first..and there were some suggestions on doing it in 
addr. he is ok with either.

My questions were to make sure we don't lose anything ...by adding it under 
link.
there is no external way to add addrs to uc and mc lists today. hence would be 
nice
to cover that case as well when we are exposing the dev uc and mc lists to 
userspace.
and ofcourse ..it does not have to be RTM_NEWADDR ...
RTM_NEWLINK can cover it both ways also.

so, if stephen has no major objections, we can still go with attributes in 
RTM_*LINK.




[PATCH net-next 1/7] net/faraday: Separate rx page storage from rxdesc

2016-09-20 Thread Joel Stanley
From: Andrew Jeffery 

The ftgmac100 hardware revision in e.g. the Aspeed AST2500 no longer
reserves all bits in RXDES#2 but instead uses the bottom 16 bits to
store MAC frame metadata. Avoid corruption by shifting struct page
pointers out to their own member in struct ftgmac100.

Signed-off-by: Andrew Jeffery 
Signed-off-by: Joel Stanley 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 25 ++---
 1 file changed, 18 insertions(+), 7 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 36361f8bf894..40622567159a 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -60,6 +60,8 @@ struct ftgmac100 {
struct ftgmac100_descs *descs;
dma_addr_t descs_dma_addr;
 
+   struct page *rx_pages[RX_QUEUE_ENTRIES];
+
unsigned int rx_pointer;
unsigned int tx_clean_pointer;
unsigned int tx_pointer;
@@ -341,18 +343,27 @@ static bool ftgmac100_rxdes_ipcs_err(struct 
ftgmac100_rxdes *rxdes)
return rxdes->rxdes1 & cpu_to_le32(FTGMAC100_RXDES1_IP_CHKSUM_ERR);
 }
 
+static inline struct page **ftgmac100_rxdes_page_slot(struct ftgmac100 *priv,
+ struct ftgmac100_rxdes 
*rxdes)
+{
+   return >rx_pages[rxdes - priv->descs->rxdes];
+}
+
 /*
  * rxdes2 is not used by hardware. We use it to keep track of page.
  * Since hardware does not touch it, we can skip cpu_to_le32()/le32_to_cpu().
  */
-static void ftgmac100_rxdes_set_page(struct ftgmac100_rxdes *rxdes, struct 
page *page)
+static void ftgmac100_rxdes_set_page(struct ftgmac100 *priv,
+struct ftgmac100_rxdes *rxdes,
+struct page *page)
 {
-   rxdes->rxdes2 = (unsigned int)page;
+   *ftgmac100_rxdes_page_slot(priv, rxdes) = page;
 }
 
-static struct page *ftgmac100_rxdes_get_page(struct ftgmac100_rxdes *rxdes)
+static struct page *ftgmac100_rxdes_get_page(struct ftgmac100 *priv,
+struct ftgmac100_rxdes *rxdes)
 {
-   return (struct page *)rxdes->rxdes2;
+   return *ftgmac100_rxdes_page_slot(priv, rxdes);
 }
 
 /**
@@ -501,7 +512,7 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, int 
*processed)
 
do {
dma_addr_t map = ftgmac100_rxdes_get_dma_addr(rxdes);
-   struct page *page = ftgmac100_rxdes_get_page(rxdes);
+   struct page *page = ftgmac100_rxdes_get_page(priv, rxdes);
unsigned int size;
 
dma_unmap_page(priv->dev, map, RX_BUF_SIZE, DMA_FROM_DEVICE);
@@ -779,7 +790,7 @@ static int ftgmac100_alloc_rx_page(struct ftgmac100 *priv,
return -ENOMEM;
}
 
-   ftgmac100_rxdes_set_page(rxdes, page);
+   ftgmac100_rxdes_set_page(priv, rxdes, page);
ftgmac100_rxdes_set_dma_addr(rxdes, map);
ftgmac100_rxdes_set_dma_own(rxdes);
return 0;
@@ -791,7 +802,7 @@ static void ftgmac100_free_buffers(struct ftgmac100 *priv)
 
for (i = 0; i < RX_QUEUE_ENTRIES; i++) {
struct ftgmac100_rxdes *rxdes = >descs->rxdes[i];
-   struct page *page = ftgmac100_rxdes_get_page(rxdes);
+   struct page *page = ftgmac100_rxdes_get_page(priv, rxdes);
dma_addr_t map = ftgmac100_rxdes_get_dma_addr(rxdes);
 
if (!page)
-- 
2.9.3



[PATCH net-next 2/7] net/faraday: Make EDO{R,T}R bits configurable

2016-09-20 Thread Joel Stanley
From: Andrew Jeffery 

These bits are #defined at a fixed location. In order to support future
hardware that has chosen to move these bits around move the bits into a
member of the struct ftgmac100.

Signed-off-by: Andrew Jeffery 
Signed-off-by: Joel Stanley 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 40 +---
 drivers/net/ethernet/faraday/ftgmac100.h |  2 --
 2 files changed, 26 insertions(+), 16 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 40622567159a..62a88d1a1f99 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -79,6 +79,9 @@ struct ftgmac100 {
int int_mask_all;
bool use_ncsi;
bool enabled;
+
+   u32 rxdes0_edorr_mask;
+   u32 txdes0_edotr_mask;
 };
 
 static int ftgmac100_alloc_rx_page(struct ftgmac100 *priv,
@@ -259,10 +262,11 @@ static bool ftgmac100_rxdes_packet_ready(struct 
ftgmac100_rxdes *rxdes)
return rxdes->rxdes0 & cpu_to_le32(FTGMAC100_RXDES0_RXPKT_RDY);
 }
 
-static void ftgmac100_rxdes_set_dma_own(struct ftgmac100_rxdes *rxdes)
+static void ftgmac100_rxdes_set_dma_own(const struct ftgmac100 *priv,
+   struct ftgmac100_rxdes *rxdes)
 {
/* clear status bits */
-   rxdes->rxdes0 &= cpu_to_le32(FTGMAC100_RXDES0_EDORR);
+   rxdes->rxdes0 &= cpu_to_le32(priv->rxdes0_edorr_mask);
 }
 
 static bool ftgmac100_rxdes_rx_error(struct ftgmac100_rxdes *rxdes)
@@ -300,9 +304,10 @@ static bool ftgmac100_rxdes_multicast(struct 
ftgmac100_rxdes *rxdes)
return rxdes->rxdes0 & cpu_to_le32(FTGMAC100_RXDES0_MULTICAST);
 }
 
-static void ftgmac100_rxdes_set_end_of_ring(struct ftgmac100_rxdes *rxdes)
+static void ftgmac100_rxdes_set_end_of_ring(const struct ftgmac100 *priv,
+   struct ftgmac100_rxdes *rxdes)
 {
-   rxdes->rxdes0 |= cpu_to_le32(FTGMAC100_RXDES0_EDORR);
+   rxdes->rxdes0 |= cpu_to_le32(priv->rxdes0_edorr_mask);
 }
 
 static void ftgmac100_rxdes_set_dma_addr(struct ftgmac100_rxdes *rxdes,
@@ -393,7 +398,7 @@ ftgmac100_rx_locate_first_segment(struct ftgmac100 *priv)
if (ftgmac100_rxdes_first_segment(rxdes))
return rxdes;
 
-   ftgmac100_rxdes_set_dma_own(rxdes);
+   ftgmac100_rxdes_set_dma_own(priv, rxdes);
ftgmac100_rx_pointer_advance(priv);
rxdes = ftgmac100_current_rxdes(priv);
}
@@ -464,7 +469,7 @@ static void ftgmac100_rx_drop_packet(struct ftgmac100 *priv)
if (ftgmac100_rxdes_last_segment(rxdes))
done = true;
 
-   ftgmac100_rxdes_set_dma_own(rxdes);
+   ftgmac100_rxdes_set_dma_own(priv, rxdes);
ftgmac100_rx_pointer_advance(priv);
rxdes = ftgmac100_current_rxdes(priv);
} while (!done && ftgmac100_rxdes_packet_ready(rxdes));
@@ -556,10 +561,11 @@ static bool ftgmac100_rx_packet(struct ftgmac100 *priv, 
int *processed)
 /**
  * internal functions (transmit descriptor)
  */
-static void ftgmac100_txdes_reset(struct ftgmac100_txdes *txdes)
+static void ftgmac100_txdes_reset(const struct ftgmac100 *priv,
+ struct ftgmac100_txdes *txdes)
 {
/* clear all except end of ring bit */
-   txdes->txdes0 &= cpu_to_le32(FTGMAC100_TXDES0_EDOTR);
+   txdes->txdes0 &= cpu_to_le32(priv->txdes0_edotr_mask);
txdes->txdes1 = 0;
txdes->txdes2 = 0;
txdes->txdes3 = 0;
@@ -580,9 +586,10 @@ static void ftgmac100_txdes_set_dma_own(struct 
ftgmac100_txdes *txdes)
txdes->txdes0 |= cpu_to_le32(FTGMAC100_TXDES0_TXDMA_OWN);
 }
 
-static void ftgmac100_txdes_set_end_of_ring(struct ftgmac100_txdes *txdes)
+static void ftgmac100_txdes_set_end_of_ring(const struct ftgmac100 *priv,
+   struct ftgmac100_txdes *txdes)
 {
-   txdes->txdes0 |= cpu_to_le32(FTGMAC100_TXDES0_EDOTR);
+   txdes->txdes0 |= cpu_to_le32(priv->txdes0_edotr_mask);
 }
 
 static void ftgmac100_txdes_set_first_segment(struct ftgmac100_txdes *txdes)
@@ -701,7 +708,7 @@ static bool ftgmac100_tx_complete_packet(struct ftgmac100 
*priv)
 
dev_kfree_skb(skb);
 
-   ftgmac100_txdes_reset(txdes);
+   ftgmac100_txdes_reset(priv, txdes);
 
ftgmac100_tx_clean_pointer_advance(priv);
 
@@ -792,7 +799,7 @@ static int ftgmac100_alloc_rx_page(struct ftgmac100 *priv,
 
ftgmac100_rxdes_set_page(priv, rxdes, page);
ftgmac100_rxdes_set_dma_addr(rxdes, map);
-   ftgmac100_rxdes_set_dma_own(rxdes);
+   ftgmac100_rxdes_set_dma_own(priv, rxdes);
return 0;
 }
 
@@ -839,7 +846,8 @@ static int 

[PATCH net-next 0/7] ftgmac100 support for ast2500

2016-09-20 Thread Joel Stanley
Hello Dave,

This series adds support to the ftgmac100 driver for the Aspeed ast2400 and
ast2500 SoCs. In particular, they ensure the driver works correctly on the
ast2500 where the MAC block has seen some changes in register layout.

They have been tested on ast2400 and ast2500 systems with the NCSI stack and
with a directly attached PHY.

Cheers,

Joel

Andrew Jeffery (2):
  net/ftgmac100: Separate rx page storage from rxdesc
  net/ftgmac100: Make EDO{R,T}R bits configurable

Gavin Shan (2):
  net/faraday: Avoid PHYSTS_CHG interrupt
  net/faraday: Clear stale interrupts

Joel Stanley (3):
  net/ftgmac100: Adapt for Aspeed SoCs
  net/faraday: Fix phy link irq on Aspeed G5 SoCs
  net/faraday: Configure old MDIO interface on Aspeed SoCs

 drivers/net/ethernet/faraday/ftgmac100.c | 92 
 drivers/net/ethernet/faraday/ftgmac100.h |  8 ++-
 2 files changed, 77 insertions(+), 23 deletions(-)

-- 
2.9.3



[PATCH net-next 3/7] net/faraday: Adapt for Aspeed SoCs

2016-09-20 Thread Joel Stanley
The RXDES and TXDES registers bits in the ftgmac100 indicates EDO{R,T}R
at bit position 15 for the Faraday Tech IP. However, the version of this
IP present in the Aspeed SoCs has these bits at position 30 in the
registers.

It appers that ast2400 SoCs support both positions, with the 15th bit
marked as reserved but still functional. In the ast2500 this bit is
reused for another function, so we need a work around.

This was confirmed with engineers from Aspeed that using bit 30 is
correct for both the ast2400 and ast2500 SoCs.

Signed-off-by: Joel Stanley 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 13 ++---
 1 file changed, 10 insertions(+), 3 deletions(-)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 62a88d1a1f99..47f512224b57 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1345,9 +1345,6 @@ static int ftgmac100_probe(struct platform_device *pdev)
priv->netdev = netdev;
priv->dev = >dev;
 
-   priv->rxdes0_edorr_mask = BIT(15);
-   priv->txdes0_edotr_mask = BIT(15);
-
spin_lock_init(>tx_lock);
 
/* initialize NAPI */
@@ -1381,6 +1378,16 @@ static int ftgmac100_probe(struct platform_device *pdev)
  FTGMAC100_INT_PHYSTS_CHG |
  FTGMAC100_INT_RPKT_BUF |
  FTGMAC100_INT_NO_RXBUF);
+
+   if (of_machine_is_compatible("aspeed,ast2400") ||
+   of_machine_is_compatible("aspeed,ast2500")) {
+   priv->rxdes0_edorr_mask = BIT(30);
+   priv->txdes0_edotr_mask = BIT(30);
+   } else {
+   priv->rxdes0_edorr_mask = BIT(15);
+   priv->txdes0_edotr_mask = BIT(15);
+   }
+
if (pdev->dev.of_node &&
of_get_property(pdev->dev.of_node, "use-ncsi", NULL)) {
if (!IS_ENABLED(CONFIG_NET_NCSI)) {
-- 
2.9.3



[PATCH net-next 5/7] net/faraday: Clear stale interrupts

2016-09-20 Thread Joel Stanley
From: Gavin Shan 

There is stale interrupt (PHYSTS_CHG in ISR, bit#6 in 0x0) from
the bootloader (uboot) when enabling the MAC. The stale interrupts
aren't part of kernel and should be cleared.

This clears the stale interrupts in ISR (0x0) when enabling the MAC.

Signed-off-by: Gavin Shan 
Signed-off-by: Joel Stanley 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 6 ++
 1 file changed, 6 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index f2ea6c2f1fbd..7ba0f2d58a8b 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1113,6 +1113,7 @@ static int ftgmac100_poll(struct napi_struct *napi, int 
budget)
 static int ftgmac100_open(struct net_device *netdev)
 {
struct ftgmac100 *priv = netdev_priv(netdev);
+   unsigned int status;
int err;
 
err = ftgmac100_alloc_buffers(priv);
@@ -1138,6 +1139,11 @@ static int ftgmac100_open(struct net_device *netdev)
 
ftgmac100_init_hw(priv);
ftgmac100_start_hw(priv, priv->use_ncsi ? 100 : 10);
+
+   /* Clear stale interrupts */
+   status = ioread32(priv->base + FTGMAC100_OFFSET_ISR);
+   iowrite32(status, priv->base + FTGMAC100_OFFSET_ISR);
+
if (netdev->phydev)
phy_start(netdev->phydev);
else if (priv->use_ncsi)
-- 
2.9.3



[PATCH net-next 4/7] net/faraday: Avoid PHYSTS_CHG interrupt

2016-09-20 Thread Joel Stanley
From: Gavin Shan 

Bit#11 in MACCR (0x50) designates the signal level for PHY link
status change. It's cleared, meaning high level enabled, by default.
However, we can see continuous interrupt (bit#6) in ISR (0x0) for it
and it's obviously a false alarm. The side effect is CPU cycles wasted
to process the false alarm.

This sets bit#11 in MACCR (0x50) to avoid the bogus interrupt.

Signed-off-by: Gavin Shan 
Signed-off-by: Joel Stanley 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 1 +
 drivers/net/ethernet/faraday/ftgmac100.h | 1 +
 2 files changed, 2 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 47f512224b57..f2ea6c2f1fbd 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -215,6 +215,7 @@ static void ftgmac100_init_hw(struct ftgmac100 *priv)
 FTGMAC100_MACCR_RXMAC_EN   | \
 FTGMAC100_MACCR_FULLDUP| \
 FTGMAC100_MACCR_CRC_APD| \
+FTGMAC100_MACCR_PHY_LINK_LEVEL | \
 FTGMAC100_MACCR_RX_RUNT| \
 FTGMAC100_MACCR_RX_BROADPKT)
 
diff --git a/drivers/net/ethernet/faraday/ftgmac100.h 
b/drivers/net/ethernet/faraday/ftgmac100.h
index c258586ce4a4..d07b6ea5d1b5 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.h
+++ b/drivers/net/ethernet/faraday/ftgmac100.h
@@ -152,6 +152,7 @@
 #define FTGMAC100_MACCR_FULLDUP(1 << 8)
 #define FTGMAC100_MACCR_GIGA_MODE  (1 << 9)
 #define FTGMAC100_MACCR_CRC_APD(1 << 10)
+#define FTGMAC100_MACCR_PHY_LINK_LEVEL (1 << 11)
 #define FTGMAC100_MACCR_RX_RUNT(1 << 12)
 #define FTGMAC100_MACCR_JUMBO_LF   (1 << 13)
 #define FTGMAC100_MACCR_RX_ALL (1 << 14)
-- 
2.9.3



[PATCH net-next 7/7] net/faraday: Configure old MDIO interface on Aspeed SoCs

2016-09-20 Thread Joel Stanley
The Aspeed SoCs have a new MDIO interface as an option in the G4 and G5
SoCs. The old one is still available, so select it in order to remain
compatible with the ftgmac100 driver.

Signed-off-by: Joel Stanley 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 9 +
 drivers/net/ethernet/faraday/ftgmac100.h | 5 +
 2 files changed, 14 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 5466df028381..54c6ba3632a3 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -1257,12 +1257,21 @@ static int ftgmac100_setup_mdio(struct net_device 
*netdev)
struct ftgmac100 *priv = netdev_priv(netdev);
struct platform_device *pdev = to_platform_device(priv->dev);
int i, err = 0;
+   u32 reg;
 
/* initialize mdio bus */
priv->mii_bus = mdiobus_alloc();
if (!priv->mii_bus)
return -EIO;
 
+   if (of_machine_is_compatible("aspeed,ast2400") ||
+   of_machine_is_compatible("aspeed,ast2500")) {
+   /* This driver supports the old MDIO interface */
+   reg = ioread32(priv->base + FTGMAC100_OFFSET_REVR);
+   reg &= ~FTGMAC100_REVR_NEW_MDIO_INTERFACE;
+   iowrite32(reg, priv->base + FTGMAC100_OFFSET_REVR);
+   };
+
priv->mii_bus->name = "ftgmac100_mdio";
snprintf(priv->mii_bus->id, MII_BUS_ID_SIZE, "%s-%d",
 pdev->name, pdev->id);
diff --git a/drivers/net/ethernet/faraday/ftgmac100.h 
b/drivers/net/ethernet/faraday/ftgmac100.h
index d07b6ea5d1b5..a7ce0ac8858a 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.h
+++ b/drivers/net/ethernet/faraday/ftgmac100.h
@@ -134,6 +134,11 @@
 #define FTGMAC100_DMAFIFOS_TXDMA_REQ   (1 << 31)
 
 /*
+ * Feature Register
+ */
+#define FTGMAC100_REVR_NEW_MDIO_INTERFACE  BIT(31)
+
+/*
  * Receive buffer size register
  */
 #define FTGMAC100_RBSR_SIZE(x) ((x) & 0x3fff)
-- 
2.9.3



[PATCH net-next 6/7] net/faraday: Fix phy link irq on Aspeed G5 SoCs

2016-09-20 Thread Joel Stanley
On Aspeed SoC with a direct PHY connection (non-NSCI), we receive
continual PHYSTS interrupts:

 [   20.28] ftgmac100 1e66.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
 [   20.28] ftgmac100 1e66.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
 [   20.28] ftgmac100 1e66.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG
 [   20.30] ftgmac100 1e66.ethernet eth0: [ISR] = 0x200: PHYSTS_CHG

This is because the driver was enabling low-level sensitive interrupt
generation where the systems are wired for high-level. All CPU cycles
are spent servicing this interrupt.

Signed-off-by: Joel Stanley 
---
 drivers/net/ethernet/faraday/ftgmac100.c | 4 
 1 file changed, 4 insertions(+)

diff --git a/drivers/net/ethernet/faraday/ftgmac100.c 
b/drivers/net/ethernet/faraday/ftgmac100.c
index 7ba0f2d58a8b..5466df028381 100644
--- a/drivers/net/ethernet/faraday/ftgmac100.c
+++ b/drivers/net/ethernet/faraday/ftgmac100.c
@@ -223,6 +223,10 @@ static void ftgmac100_start_hw(struct ftgmac100 *priv, int 
speed)
 {
int maccr = MACCR_ENABLE_ALL;
 
+   if (of_machine_is_compatible("aspeed,ast2500")) {
+   maccr &= ~FTGMAC100_MACCR_PHY_LINK_LEVEL;
+   }
+
switch (speed) {
default:
case 10:
-- 
2.9.3



[PATCHv2 net] cxgb4/cxgb4vf: Allocate more queues for 25G and 100G adapter

2016-09-20 Thread Hariprasad Shenai
We were missing check for 25G and 100G while checking port speed,
which lead to less number of queues getting allocated for 25G & 100G
adapters and leading to low throughput. Adding the missing check for
both NIC and vNIC driver.

Also fixes port advertisement for 25G and 100G in ethtool output.

Signed-off-by: Hariprasad Shenai 
---
V2: Missed 25G in the first one

 drivers/net/ethernet/chelsio/cxgb4/cxgb4.h |  4 ++--
 drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c| 15 +--
 drivers/net/ethernet/chelsio/cxgb4/t4_hw.c |  7 ++-
 drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h  |  6 ++
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_common.h | 15 +++
 drivers/net/ethernet/chelsio/cxgb4vf/t4vf_hw.c |  9 +++--
 6 files changed, 45 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
index 2e2aa9fec9bb..edd23386b47d 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4.h
@@ -419,8 +419,8 @@ struct link_config {
unsigned short supported;/* link capabilities */
unsigned short advertising;  /* advertised capabilities */
unsigned short lp_advertising;   /* peer advertised capabilities */
-   unsigned short requested_speed;  /* speed user has requested */
-   unsigned short speed;/* actual link speed */
+   unsigned int   requested_speed;  /* speed user has requested */
+   unsigned int   speed;/* actual link speed */
unsigned char  requested_fc; /* flow control user has requested */
unsigned char  fc;   /* actual link flow control */
unsigned char  autoneg;  /* autonegotiating? */
diff --git a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c 
b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
index c762a8c8c954..3ceafb55d6da 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/cxgb4_main.c
@@ -4305,10 +4305,17 @@ static const struct pci_error_handlers cxgb4_eeh = {
.resume = eeh_resume,
 };
 
+/* Return true if the Link Configuration supports "High Speeds" (those greater
+ * than 1Gb/s).
+ */
 static inline bool is_x_10g_port(const struct link_config *lc)
 {
-   return (lc->supported & FW_PORT_CAP_SPEED_10G) != 0 ||
-  (lc->supported & FW_PORT_CAP_SPEED_40G) != 0;
+   unsigned int speeds, high_speeds;
+
+   speeds = FW_PORT_CAP_SPEED_V(FW_PORT_CAP_SPEED_G(lc->supported));
+   high_speeds = speeds & ~(FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G);
+
+   return high_speeds != 0;
 }
 
 static inline void init_rspq(struct adapter *adap, struct sge_rspq *q,
@@ -4756,8 +4763,12 @@ static void print_port_info(const struct net_device *dev)
bufp += sprintf(bufp, "1000/");
if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_10G)
bufp += sprintf(bufp, "10G/");
+   if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_25G)
+   bufp += sprintf(bufp, "25G/");
if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_40G)
bufp += sprintf(bufp, "40G/");
+   if (pi->link_cfg.supported & FW_PORT_CAP_SPEED_100G)
+   bufp += sprintf(bufp, "100G/");
if (bufp != buf)
--bufp;
sprintf(bufp, "BASE-%s", t4_get_port_type_description(pi->port_type));
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c 
b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
index dc92c80a75f4..660204bff726 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4_hw.c
@@ -3627,7 +3627,8 @@ void t4_ulprx_read_la(struct adapter *adap, u32 *la_buf)
 }
 
 #define ADVERT_MASK (FW_PORT_CAP_SPEED_100M | FW_PORT_CAP_SPEED_1G |\
-FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_SPEED_40G | \
+FW_PORT_CAP_SPEED_10G | FW_PORT_CAP_SPEED_25G | \
+FW_PORT_CAP_SPEED_40G | FW_PORT_CAP_SPEED_100G | \
 FW_PORT_CAP_ANEG)
 
 /**
@@ -7196,8 +7197,12 @@ void t4_handle_get_port_info(struct port_info *pi, const 
__be64 *rpl)
speed = 1000;
else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_10G))
speed = 1;
+   else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_25G))
+   speed = 25000;
else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_40G))
speed = 4;
+   else if (stat & FW_PORT_CMD_LSPEED_V(FW_PORT_CAP_SPEED_100G))
+   speed = 10;
 
lc = >link_cfg;
 
diff --git a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h 
b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
index a89b30720e38..30507d44422c 100644
--- a/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
+++ b/drivers/net/ethernet/chelsio/cxgb4/t4fw_api.h
@@ -2265,6 +2265,12 @@ enum 

Re: [PATCH net] cxgb4/cxgb4vf: Allocate more queues for 100G adapter

2016-09-20 Thread Hariprasad Shenai
On Mon, Sep 19, 2016 at 01:32:46PM +0530, Hariprasad Shenai wrote:
> We were missing check for 100G while checking port speed, which lead to
> less number of queues getting allocated for 100G and leading to low
> throughput. Adding the missing check for both NIC and vNIC driver.
> 
> Signed-off-by: Hariprasad Shenai 
> ---

Hi David,

I missed 25G, will send a V2 for the same with changes for 25Gbps adapter too.

Thanks,
Hari 


Re: [patch net-next RFC 0/2] fib4 offload: notifier to let hw to be aware of all prefixes

2016-09-20 Thread Roopa Prabhu
On Mon, Sep 19, 2016 at 11:02 PM, Jiri Pirko  wrote:
> Tue, Sep 20, 2016 at 07:49:47AM CEST, ro...@cumulusnetworks.com wrote:

[snip]

>>
>>Do you see any scale problems with using notifiers ?. as you know these ascis 
>>can scale to
>>32k-128k routes.
>
> I don't see any problem there. What do you think might be wrong?
>

we had seen some overheads with link notifiers in older kernels with
large number of links flaps.
But that could have been due to rtnl lock. don't have any more data
than that. so, ignore that.
I don't see anything obvious from perf perspectivertnl is already
held. but, thought i did just ask.


Re: [patch net-next RFC 0/2] fib4 offload: notifier to let hw to be aware of all prefixes

2016-09-20 Thread Jiri Pirko
Tue, Sep 20, 2016 at 07:49:47AM CEST, ro...@cumulusnetworks.com wrote:
>On 9/19/16, 8:15 AM, Jiri Pirko wrote:
>> Mon, Sep 19, 2016 at 04:59:22PM CEST, ro...@cumulusnetworks.com wrote:
>>> On 9/18/16, 11:14 PM, Jiri Pirko wrote:
 Mon, Sep 19, 2016 at 01:16:17AM CEST, ro...@cumulusnetworks.com wrote:
> On 9/18/16, 1:00 PM, Florian Fainelli wrote:
>> Le 06/09/2016 à 05:01, Jiri Pirko a écrit :
>>> From: Jiri Pirko 
>>>
>>> This is RFC, unfinished. I came across some issues in the process so I 
>>> would
>>> like to share those and restart the fib offload discussion in order to 
>>> make it
>>> really usable.
>>>
>>> So the goal of this patchset is to allow driver to propagate all 
>>> prefixes
>>> configured in kernel down HW. This is necessary for routing to work
>>> as expected. If we don't do that HW might forward prefixes known to 
>>> kernel
>>> incorrectly. Take an example when default route is set in switch HW and 
>>> there
>>> is an IP address set on a management (non-switch) port.
>>>
>>> Currently, only fibs related to the switch port netdev are offloaded 
>>> using
>>> switchdev ops. This model is not extendable so the first patch 
>>> introduces
>>> a replacement: notifier to propagate fib additions and removals to 
>>> whoever
>>> interested. The second patch makes mlxsw to adopt this new way, 
>>> registering
>>> one notifier block for each mlxsw (asic) instance.
>> Instead of introducing another specialization of a notifier_block
>> implementation, could we somehow have a kernel-based netlink listener
>> which receives the same kind of event information from rtmsg_fib()?
>>
>> The reason is that having such a facility would hook directly onto
>> existing rtmsg_* calls that exist throughout the stack, and that seems
>> to scale better.
> I was thinking along the same lines. Instead of proliferating notifier 
> blocks
> through-out the stack for switchdev offload, putting existing events to 
> use would be nice.
>
> But the problem though is drivers having to parse the netlink msg again. 
> also, the intent
> here is to do the offload first ..before the route is added to the kernel 
> (though i don't see that in
> the current series). existing netlink rmsg_fib events are generated after 
> the route is added to the kernel.
>
>
> Jiri, instead of the notifier, do you see a problem with always calling 
> the existing switchdev
> offload api for every route  for every asic instance ?. the first device 
> where the route fits wins.
 There is not list of asic instances. Therefore the notifier fits much 
 better here.



> it seems similar to driver registering for notifier and looking at every 
> route ...
> am i missing something ?
> and the policies you mention could help around selecting the asic 
> instance (FCFS or mirror).
> you will need to abstract out the asic instance for switchdev api to call 
> on, but I thought you
> already have that in some form in your devlink infrastructure.
 switchdev asic instances and devlink instances are orthogonal.
>>> maybe it is not today...but the requirement for devlink was to provide a 
>>> way to communicate
>>> to the switch driver
>>> - global switch attributes or
>>> - things that cannot go via switch ports (exactly the problem you are 
>>> trying to solve for routes here)
>> Devlink is a general beast, not switch specific one. I see no need to
>> use fib->devlink->driver route inside kernel. Devlink is for userspace
>> facing.
>
>yes, sure. it has a dev abstraction and an api. devlink discussion started a 
>few years ago in the context
>of switch asics for the very same reason that it will help direct the offload 
>call to the
>switch device driver when you cant apply the settings on a per port basis.
>You have kept the abstraction and api generic ..which is a great thing.
>But that can't be the reason for it to not support its original intent...if 
>there is a way.
>
>>
>>
>>> so,  maybe an instance of switch asic modeled via devlink will help here 
>>> and possibly all/other switchdev
>>> offload hooks ?
>> Maybe, but in case of fibs, the notifier just fits great. I see no need
>> for anything else.
>
>I think its better to stick with 'offload api or notifier' whichever we pick ..
>to be consistent with other switchdev offload areas. That was the original 
>intent of
>introducing the switchdev api layer. If we are now replacing the switchdev api 
>with notifiers,

I strongly disagree. Make it uniform is not desirable. For some things,
direct ndo/sdo make sense and is better. For some other things, notifier
fits better. For example when I was implementing LAG offload,
I also chose a notifier.


>assuming 'notifiers are the best way' to offload routes, lets keep it 

[PATCH v3] iproute2: build nsid-name cache only for commands that need it

2016-09-20 Thread Anton Aksola
The calling of netns_map_init() before command parsing introduced
a performance issue with large number of namespaces.

As commands such as add, del and exec do not need to iterate through
/var/run/netns it would be good not no build the cache before executing
these commands.

Example:
unpatched:
time seq 1 1000 | xargs -n 1 ip netns add

real0m16.832s
user0m1.350s
sys0m15.029s

patched:
time seq 1 1000 | xargs -n 1 ip netns add

real0m3.859s
user0m0.132s
sys0m3.205s

Signed-off-by: Anton Aksola 
---
 ip/ip_common.h|  1 +
 ip/ipmonitor.c|  1 +
 ip/ipnetns.c  | 31 ++-
 testsuite/tests/ip/netns/set_nsid.t   | 22 ++
 testsuite/tests/ip/netns/set_nsid_batch.t | 18 ++
 5 files changed, 64 insertions(+), 9 deletions(-)
 create mode 100755 testsuite/tests/ip/netns/set_nsid.t
 create mode 100755 testsuite/tests/ip/netns/set_nsid_batch.t

diff --git a/ip/ip_common.h b/ip/ip_common.h
index 93ff5bc..fabc4b5 100644
--- a/ip/ip_common.h
+++ b/ip/ip_common.h
@@ -31,6 +31,7 @@ int print_netconf(const struct sockaddr_nl *who,
  struct rtnl_ctrl_data *ctrl,
  struct nlmsghdr *n, void *arg);
 void netns_map_init(void);
+void netns_nsid_socket_init(void);
 int print_nsid(const struct sockaddr_nl *who,
   struct nlmsghdr *n, void *arg);
 int do_ipaddr(int argc, char **argv);
diff --git a/ip/ipmonitor.c b/ip/ipmonitor.c
index 2090a45..c892b8f 100644
--- a/ip/ipmonitor.c
+++ b/ip/ipmonitor.c
@@ -301,6 +301,7 @@ int do_ipmonitor(int argc, char **argv)
exit(1);
 
ll_init_map();
+   netns_nsid_socket_init();
netns_map_init();
 
if (rtnl_listen(, accept_msg, stdout) < 0)
diff --git a/ip/ipnetns.c b/ip/ipnetns.c
index af87065..6b42751 100644
--- a/ip/ipnetns.c
+++ b/ip/ipnetns.c
@@ -194,6 +194,18 @@ static void netns_map_del(struct nsid_cache *c)
free(c);
 }
 
+void netns_nsid_socket_init(void)
+{
+   if (rtnsh.fd > -1 || !ipnetns_have_nsid())
+   return;
+
+   if (rtnl_open(, 0) < 0) {
+   fprintf(stderr, "Cannot open rtnetlink\n");
+   exit(1);
+   }
+
+}
+
 void netns_map_init(void)
 {
static int initialized;
@@ -204,11 +216,6 @@ void netns_map_init(void)
if (initialized || !ipnetns_have_nsid())
return;
 
-   if (rtnl_open(, 0) < 0) {
-   fprintf(stderr, "Cannot open rtnetlink\n");
-   exit(1);
-   }
-
dir = opendir(NETNS_RUN_DIR);
if (!dir)
return;
@@ -775,17 +782,23 @@ static int netns_monitor(int argc, char **argv)
 
 int do_netns(int argc, char **argv)
 {
-   netns_map_init();
+   netns_nsid_socket_init();
 
-   if (argc < 1)
+   if (argc < 1) {
+   netns_map_init();
return netns_list(0, NULL);
+   }
 
if ((matches(*argv, "list") == 0) || (matches(*argv, "show") == 0) ||
-   (matches(*argv, "lst") == 0))
+   (matches(*argv, "lst") == 0)) {
+   netns_map_init();
return netns_list(argc-1, argv+1);
+   }
 
-   if ((matches(*argv, "list-id") == 0))
+   if ((matches(*argv, "list-id") == 0)) {
+   netns_map_init();
return netns_list_id(argc-1, argv+1);
+   }
 
if (matches(*argv, "help") == 0)
return usage();
diff --git a/testsuite/tests/ip/netns/set_nsid.t 
b/testsuite/tests/ip/netns/set_nsid.t
new file mode 100755
index 000..606d45a
--- /dev/null
+++ b/testsuite/tests/ip/netns/set_nsid.t
@@ -0,0 +1,22 @@
+#!/bin/sh
+
+source lib/generic.sh
+
+ts_log "[Testing netns nsid]"
+
+NS=testnsid
+NSID=99
+
+ts_ip "$0" "Add new netns $NS" netns add $NS
+ts_ip "$0" "Set $NS nsid to $NSID" netns set $NS $NSID
+
+ts_ip "$0" "List netns" netns list
+test_on "$NS \(id: $NSID\)"
+
+ts_ip "$0" "List netns without explicit list or show" netns
+test_on "$NS \(id: $NSID\)"
+
+ts_ip "$0" "List nsid" netns list-id
+test_on "$NSID \(iproute2 netns name: $NS\)"
+
+ts_ip "$0" "Delete netns $NS" netns del $NS
diff --git a/testsuite/tests/ip/netns/set_nsid_batch.t 
b/testsuite/tests/ip/netns/set_nsid_batch.t
new file mode 100755
index 000..abb3f1b
--- /dev/null
+++ b/testsuite/tests/ip/netns/set_nsid_batch.t
@@ -0,0 +1,18 @@
+#!/bin/sh
+
+source lib/generic.sh
+
+ts_log "[Testing netns nsid in batch mode]"
+
+NS=testnsid
+NSID=99
+BATCHFILE=`mktemp`
+
+echo "netns add $NS" >> $BATCHFILE
+echo "netns set $NS $NSID" >> $BATCHFILE
+echo "netns list-id" >> $BATCHFILE
+ts_ip "$0" "Add ns, set nsid and list in batch mode" -b $BATCHFILE
+test_on "nsid $NSID \(iproute2 netns name: $NS\)"
+rm -f $BATCHFILE
+
+ts_ip "$0" "Delete netns $NS" netns del $NS
-- 
1.8.3.1



<    1   2   3   4