[PATCH net-next] tun: fix build warnings

2016-07-03 Thread Jason Wang
Stephen Rothwell reports a build warnings(powerpc ppc64_defconfig)

drivers/net/tun.c: In function 'tun_do_read.part.5':
/home/sfr/next/next/drivers/net/tun.c:1491:6: warning: 'err' may be
used uninitialized in this function [-Wmaybe-uninitialized]
   int err;

This is because tun_ring_recv() may return an uninitialized err, fix this.

Reported-by: Stephen Rothwell 
Signed-off-by: Jason Wang 
---
 drivers/net/tun.c | 8 +---
 1 file changed, 5 insertions(+), 3 deletions(-)

diff --git a/drivers/net/tun.c b/drivers/net/tun.c
index 7475215..5eadb7a 100644
--- a/drivers/net/tun.c
+++ b/drivers/net/tun.c
@@ -1447,12 +1447,13 @@ static struct sk_buff *tun_ring_recv(struct tun_file 
*tfile, int noblock,
 {
DECLARE_WAITQUEUE(wait, current);
struct sk_buff *skb = NULL;
+   int error = 0;
 
skb = skb_array_consume(>tx_array);
if (skb)
goto out;
if (noblock) {
-   *err = -EAGAIN;
+   error = -EAGAIN;
goto out;
}
 
@@ -1464,11 +1465,11 @@ static struct sk_buff *tun_ring_recv(struct tun_file 
*tfile, int noblock,
if (skb)
break;
if (signal_pending(current)) {
-   *err = -ERESTARTSYS;
+   error = -ERESTARTSYS;
break;
}
if (tfile->socket.sk->sk_shutdown & RCV_SHUTDOWN) {
-   *err = -EFAULT;
+   error = -EFAULT;
break;
}
 
@@ -1479,6 +1480,7 @@ static struct sk_buff *tun_ring_recv(struct tun_file 
*tfile, int noblock,
remove_wait_queue(>wq.wait, );
 
 out:
+   *err = error;
return skb;
 }
 
-- 
2.7.4



Re: [PATCH] netfilter: nf_conntrack_sip: CSeq 0 is a valid CSeq

2016-07-03 Thread Liping Zhang
2016-07-01 17:48 GMT+08:00 Christophe Leroy :
> Do not drop packet when CSeq is 0 as 0 is also a valid value for CSeq.
>
> --- a/net/netfilter/nf_conntrack_sip.c
> +++ b/net/netfilter/nf_conntrack_sip.c
> @@ -1368,6 +1368,7 @@ static int process_sip_response(struct sk_buff *skb, 
> unsigned int protoff,
> struct nf_conn *ct = nf_ct_get(skb, );
> unsigned int matchoff, matchlen, matchend;
> unsigned int code, cseq, i;
> +   char buf[21];
>
> if (*datalen < strlen("SIP/2.0 200"))
> return NF_ACCEPT;
> @@ -1382,8 +1383,13 @@ static int process_sip_response(struct sk_buff *skb, 
> unsigned int protoff,
> nf_ct_helper_log(skb, ct, "cannot parse cseq");
> return NF_DROP;
> }
> -   cseq = simple_strtoul(*dptr + matchoff, NULL, 10);
> -   if (!cseq) {

I think there is no need to convert simple_strtoul to kstrtouint, add
a further check seems better?
Like this:
 -   if (!cseq) {
+   if (!cseq && *(*dptr + matchoff) != '0') {

> +   if (matchlen > sizeof(buf) - 1) {
> +   nf_ct_helper_log(skb, ct, "cannot parse cseq (too big)");
> +   return NF_DROP;
> +   }
> +   memcpy(buf, *dptr + matchoff, matchlen);
> +   buf[matchlen] = 0;
> +   if (kstrtouint(buf, 10, )) {
> nf_ct_helper_log(skb, ct, "cannot get cseq");
> return NF_DROP;
> }


[PATCH] fsl/fman: fix error handling

2016-07-03 Thread Christophe JAILLET
This is likely that checking 'fman->fifo_offset' instead of
'fman->cam_offset' is expected here.

Signed-off-by: Christophe JAILLET 

---

The type of 'fifo_offset' may also need to be changed.
---
 drivers/net/ethernet/freescale/fman/fman.c | 2 +-
 1 file changed, 1 insertion(+), 1 deletion(-)

diff --git a/drivers/net/ethernet/freescale/fman/fman.c 
b/drivers/net/ethernet/freescale/fman/fman.c
index 1de2e1e..f634e769 100644
--- a/drivers/net/ethernet/freescale/fman/fman.c
+++ b/drivers/net/ethernet/freescale/fman/fman.c
@@ -2036,7 +2036,7 @@ static int fman_init(struct fman *fman)
/* allocate MURAM for FIFO according to total size */
fman->fifo_offset = fman_muram_alloc(fman->muram,
 fman->state->total_fifo_size);
-   if (IS_ERR_VALUE(fman->cam_offset)) {
+   if (IS_ERR_VALUE(fman->fifo_offset)) {
free_init_resources(fman);
dev_err(fman->dev, "%s: MURAM alloc for BMI FIFO failed\n",
__func__);
-- 
2.7.4



Re: linux-next: build warning after merge of the net-next tree

2016-07-03 Thread Jason Wang



On 2016年07月04日 11:15, Stephen Rothwell wrote:

Hi all,

After merging the net-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:

drivers/net/tun.c: In function 'tun_do_read.part.5':
/home/sfr/next/next/drivers/net/tun.c:1491:6: warning: 'err' may be used 
uninitialized in this function [-Wmaybe-uninitialized]
   int err;
   ^

Introduced by commit

   1576d9860599 ("tun: switch to use skb array for tx")

I can't easily see if this is a false positive.



Thanks for the reporting, will post a fix.


Re^2: [PATCH] usbnet: add reset_resume quirk to prevent resume failure

2016-07-03 Thread Vivek Kumar Bhagat
Hello David,

Class driver .reset_resume() function will be called only when USB host driver 
has
set below flag, otherwise it will follow normal resume (without reset).
if (udev->quirks & USB_QUIRK_RESET_RESUME)   <-- usb_resume_device()
udev->reset_resume = 1;

I shall remove cdc_eem changes, then it would be applicable for asix 2.0 device 
only. 
I shall make one patch for asix 2.0 (asix_devices.c) and asix 3.0 
(ax88179_178a.c).
We have verified on almost all type of available asix dongle.
I hope it would be okay.

Regards,
Vivek
--- Original Message ---
Sender : David Miller
Date : Jul 02, 2016 01:28 (GMT+05:30)
Title : Re: [PATCH] usbnet: add reset_resume quirk to prevent resume failure

From: Vivek Kumar Bhagat 
Date: Thu, 30 Jun 2016 10:41:59 + (GMT)

> 
> Ideally, usbnet_resume is sufficient for device resume operation.
> since usbcore function usb_resume_device() sets udev->reset_resume
> flag as a quirk solution, reset_resume() quirk we can keep in
> class driver also. We checked on dongle DA-Queen UFE20C,
> without reset function resume operation fails. Reason could be
> some power glitch during suspend time due to which device lose
> its internal state and it needs a device phy reset again during
> resume to recover.
> 
> Signed-off-by: Vivek Kumar Bhagat 
> Signed-off-by: Vikas Bansal 
> Signed-off-by: Sangmin Bae 

You've seen this necessary for one device, yet you are doing this
new reset for all usbnet devices.

That doesn't sound correct or safe at all.

I'm not applying this, sorry.

PROBLEM: MTU of ipsec tunnel drops continuously until traffic stops

2016-07-03 Thread Matt Bennett
*Resending as plain text so the mailing list accepts it.. Sorry Steffen and 
Herbert*

​Hi,

During long run testing of an ipsec tunnel over a PPP link it was found that 
occasionally traffic would stop flowing over the tunnel. Eventually the traffic 
would start again, however using the command "ip route flush cache" causes 
traffic to start flowing  again immediately.

Note, I am using a 4.4.6 based kernel, however I see no major differences 
between 4.4.6 and 4.4.14 (current LTS) in any of the code I am debugging. I  
have manually debugged the code as far as I can, however I don't know the code 
well enough to make further progress. What I have uncovered is outlined below:

By pinging the other end of the tunnel when the traffic stops flowing I get 
messages like the following:

10-AR4050#ping 172.16.0.5
PING 172.16.0.5 (172.16.0.5) 56(84) bytes of data.
From 172.16.0.6 icmp_seq=1 Frag needed and DF set (mtu = 46)
From 172.16.0.6 icmp_seq=2 Frag needed and DF set (mtu = 46)

but this is weird considering (note the mtu values):

[root@10-AR4050 /flash]# ip link
16778240: ppp0:  mtu 1492 qdisc htb 
state UP mode DEFAULT group default qlen 3
    link/ppp 
14: tunnel64@NONE:  mtu 1200 qdisc htb state 
UNKNOWN mode DEFAULT group default qlen 1
    link/ipip 203.0.113.10 peer 203.0.113.5

The code that generates the ICMP_FRAG_NEEDED packet is vti_xmit() (ip_vti.c) 
where there is a check of skb length against the mtu of dst entry. Since the 
mtu is lower than the packet (debug shows the mtu is 46 as expected from the 
ping output) the ICMP  error is generated.

Digging further I find that when the issue occurs the mtu value is being 
updated in what appears to be an error case in xfrm_bundle_ok (xfrm_policy.c). 
Specifically the block of code:

if (likely(!last))
return 1;

is not hit meaning there is a difference between the cached mtu value and the 
value just calculated. I then see this code being hit continuously and each 
time the mtu keeps getting lowered. i.e. (I don't know if the drop by 80 bytes 
is significant)

1200
1118
1038
958
878
 
46

At this point I don't know how to debug further. It appears there is a 
disparity between cached mtu values and what is calculated in xfrm_bundle_ok(). 
Hopefully this is enough information to explain the problem I am seeing. Please 
let me know if you need more information.

Thanks,
Matt

linux-next: build warning after merge of the net-next tree

2016-07-03 Thread Stephen Rothwell
Hi all,

After merging the net-next tree, today's linux-next build (powerpc
ppc64_defconfig) produced this warning:

drivers/net/tun.c: In function 'tun_do_read.part.5':
/home/sfr/next/next/drivers/net/tun.c:1491:6: warning: 'err' may be used 
uninitialized in this function [-Wmaybe-uninitialized]
  int err;
  ^

Introduced by commit

  1576d9860599 ("tun: switch to use skb array for tx")

I can't easily see if this is a false positive.

-- 
Cheers,
Stephen Rothwell


linux-next: manual merge of the net-next tree with the net tree

2016-07-03 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got a conflict in:

  drivers/net/ethernet/mellanox/mlx5/core/en_main.c

between commit:

  29429f3300a3 ("net/mlx5e: Timeout if SQ doesn't flush during close")

from the net tree and commit:

  507f0c817f7a ("net/mlx5e: Add TXQ set max rate support")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/net/ethernet/mellanox/mlx5/core/en_main.c
index 7a0dca29c642,96ec53a6a595..
--- a/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en_main.c
@@@ -39,16 -39,10 +39,17 @@@
  #include "eswitch.h"
  #include "vxlan.h"
  
 +enum {
 +  MLX5_EN_QP_FLUSH_TIMEOUT_MS = 5000,
 +  MLX5_EN_QP_FLUSH_MSLEEP_QUANT   = 20,
 +  MLX5_EN_QP_FLUSH_MAX_ITER   = MLX5_EN_QP_FLUSH_TIMEOUT_MS /
 +MLX5_EN_QP_FLUSH_MSLEEP_QUANT,
 +};
 +
  struct mlx5e_rq_param {
-   u32rqc[MLX5_ST_SZ_DW(rqc)];
-   struct mlx5_wq_param   wq;
+   u32 rqc[MLX5_ST_SZ_DW(rqc)];
+   struct mlx5_wq_paramwq;
+   boolam_enabled;
  };
  
  struct mlx5e_sq_param {
@@@ -574,8 -543,9 +582,10 @@@ static void mlx5e_close_rq(struct mlx5e
/* avoid destroying rq before mlx5e_poll_rx_cq() is done with it */
napi_synchronize(>channel->napi);
  
+   cancel_work_sync(>am.work);
+ 
mlx5e_disable_rq(rq);
 +  mlx5e_free_rx_descs(rq);
mlx5e_destroy_rq(rq);
  }
  
@@@ -835,19 -810,12 +853,19 @@@ static void mlx5e_close_sq(struct mlx5e
if (mlx5e_sq_has_room_for(sq, 1))
mlx5e_send_nop(sq, true);
  
 -  mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY, MLX5_SQC_STATE_ERR,
 -  false, 0);
 +  err = mlx5e_modify_sq(sq, MLX5_SQC_STATE_RDY,
- MLX5_SQC_STATE_ERR);
++MLX5_SQC_STATE_ERR, false, 0);
 +  if (err)
 +  set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, >state);
}
  
 -  while (sq->cc != sq->pc) /* wait till sq is empty */
 -  msleep(20);
 +  /* wait till sq is empty, unless a TX timeout occurred on this SQ */
 +  while (sq->cc != sq->pc &&
 + !test_bit(MLX5E_SQ_STATE_TX_TIMEOUT, >state)) {
 +  msleep(MLX5_EN_QP_FLUSH_MSLEEP_QUANT);
 +  if (tout++ > MLX5_EN_QP_FLUSH_MAX_ITER)
 +  set_bit(MLX5E_SQ_STATE_TX_TIMEOUT, >state);
 +  }
  
/* avoid destroying sq before mlx5e_poll_tx_cq() is done with it */
napi_synchronize(>channel->napi);


linux-next: manual merge of the net-next tree with the net tree

2016-07-03 Thread Stephen Rothwell
Hi all,

Today's linux-next merge of the net-next tree got a conflict in:

  drivers/net/ethernet/mellanox/mlx5/core/en.h

between commit:

  6cd392a082de ("net/mlx5e: Handle RQ flush in error cases")

from the net tree and commit:

  cb3c7fd4f839 ("net/mlx5e: Support adaptive RX coalescing")

from the net-next tree.

I fixed it up (see below) and can carry the fix as necessary. This
is now fixed as far as linux-next is concerned, but any non trivial
conflicts should be mentioned to your upstream maintainer when your tree
is submitted for merging.  You may also want to consider cooperating
with the maintainer of the conflicting tree to minimise any particularly
complex conflicts.

-- 
Cheers,
Stephen Rothwell

diff --cc drivers/net/ethernet/mellanox/mlx5/core/en.h
index 943b1bd434bf,00643a116492..
--- a/drivers/net/ethernet/mellanox/mlx5/core/en.h
+++ b/drivers/net/ethernet/mellanox/mlx5/core/en.h
@@@ -143,10 -146,32 +146,31 @@@ struct mlx5e_umr_wqe 
struct mlx5_wqe_data_seg   data;
  };
  
+ static const char mlx5e_priv_flags[][ETH_GSTRING_LEN] = {
+   "rx_cqe_moder",
+ };
+ 
+ enum mlx5e_priv_flag {
+   MLX5E_PFLAG_RX_CQE_BASED_MODER = (1 << 0),
+ };
+ 
+ #define MLX5E_SET_PRIV_FLAG(priv, pflag, enable)\
+   do {\
+   if (enable) \
+   priv->pflags |= pflag;  \
+   else\
+   priv->pflags &= ~pflag; \
+   } while (0)
+ 
  #ifdef CONFIG_MLX5_CORE_EN_DCB
  #define MLX5E_MAX_BW_ALLOC 100 /* Max percentage of BW allocation */
 -#define MLX5E_MIN_BW_ALLOC 1   /* Min percentage of BW allocation */
  #endif
  
+ struct mlx5e_cq_moder {
+   u16 usec;
+   u16 pkts;
+ };
+ 
  struct mlx5e_params {
u8  log_sq_size;
u8  rq_wq_type;
@@@ -190,7 -215,7 +214,8 @@@ struct mlx5e_tstamp 
  enum {
MLX5E_RQ_STATE_POST_WQES_ENABLE,
MLX5E_RQ_STATE_UMR_WQE_IN_PROGRESS,
 +  MLX5E_RQ_STATE_FLUSH_TIMEOUT,
+   MLX5E_RQ_STATE_AM,
  };
  
  struct mlx5e_cq {
@@@ -542,9 -610,9 +614,10 @@@ struct mlx5e_priv 
struct workqueue_struct*wq;
struct work_struct update_carrier_work;
struct work_struct set_rx_mode_work;
 +  struct work_struct tx_timeout_work;
struct delayed_workupdate_stats_work;
  
+   u32pflags;
struct mlx5_core_dev  *mdev;
struct net_device *netdev;
struct mlx5e_stats stats;


Re: [PATCH net-next 00/10] NCSI Support

2016-07-03 Thread Gavin Shan
On Mon, Jul 04, 2016 at 08:49:31AM +1000, Benjamin Herrenschmidt wrote:
>On Mon, 2016-07-04 at 01:03 +0300, Or Gerlitz wrote:
>> FWIW, talking to a colleague, he made a comment that some of the text
>> above is wrong:
>> 
>> AENs are sent from NIC to BMC. Not from Host to BMC.
>
>Just a typo in the commit message thankfully ;-)
>

Yeah, the AENs are sent from NIC to BMC and the code follows it. The code
is tested on IBM's openPower server where a BMC (ARM system) and host (
Power system and NIC) are included. So the host, the far end and NIC can
be regarded as equivalents.

>> The traffic between a BMC and a NIC is over RBT if it is formatted as
>> NC-SI packets. This is not over network traffic
>

It's correct. The figure included in the commit log might give the illusion
that NCSI packets are sent over network traffic.

Thanks,
Gavin



Re: [PATCH] mwifiex: fix unconditional error return in .add_virtual_intf callback

2016-07-03 Thread Julian Calaby
Hi All,

On Sat, Jul 2, 2016 at 5:39 AM, Javier Martinez Canillas
 wrote:
> The commit 7311ea850079 ("mwifiex: fix AP start problem for newly added
> interface") attempted to fix an issue when a new AP interface is added.
>
> But the patch didn't check the return value of the functions doing the
> firmware calls and returned an error even if the functions didn't fail.
>
> This prevents the network device to be registered properly, so fix it.
>
> Fixes: commit 7311ea850079 ("mwifiex: fix AP start problem for newly added 
> interface")
> Signed-off-by: Javier Martinez Canillas 

Looks correct to me as Dan Carpenter submitted the same fix.

Reviewed-by: Julian Calaby 

Thanks,

-- 
Julian Calaby

Email: julian.cal...@gmail.com
Profile: http://www.google.com/profiles/julian.calaby/


Re: [PATCH net-next 00/10] NCSI Support

2016-07-03 Thread Benjamin Herrenschmidt
On Mon, 2016-07-04 at 01:03 +0300, Or Gerlitz wrote:
> FWIW, talking to a colleague, he made a comment that some of the text
> above is wrong:
> 
> AENs are sent from NIC to BMC. Not from Host to BMC.

Just a typo in the commit message thankfully ;-)

> The traffic between a BMC and a NIC is over RBT if it is formatted as
> NC-SI packets. This is not over network traffic


Re: [PATCH] [v6] net: emac: emac gigabit ethernet controller driver

2016-07-03 Thread Lino Sanfilippo
Hi,

some remarks below.

> +/* Fill up receive queue's RFD with preallocated receive buffers */
> +static void emac_mac_rx_descs_refill(struct emac_adapter *adpt,
> + struct emac_rx_queue *rx_q)
> +{
> + struct emac_buffer *curr_rxbuf;
> + struct emac_buffer *next_rxbuf;
> + unsigned int count = 0;
> + u32 next_produce_idx;
> +
> + next_produce_idx = rx_q->rfd.produce_idx + 1;
> + if (next_produce_idx == rx_q->rfd.count)
> + next_produce_idx = 0;
> +
> + curr_rxbuf = GET_RFD_BUFFER(rx_q, rx_q->rfd.produce_idx);
> + next_rxbuf = GET_RFD_BUFFER(rx_q, next_produce_idx);
> +
> + /* this always has a blank rx_buffer*/
> + while (!next_rxbuf->dma_addr) {
> + struct sk_buff *skb;
> + void *skb_data;
> +
> + skb = dev_alloc_skb(adpt->rxbuf_size + NET_IP_ALIGN);
> + if (!skb)
> + break;
> +
> + /* Make buffer alignment 2 beyond a 16 byte boundary
> +  * this will result in a 16 byte aligned IP header after
> +  * the 14 byte MAC header is removed
> +  */
> + skb_reserve(skb, NET_IP_ALIGN);

__netdev_alloc_skb_ip_align will do this for you.


> + skb_data = skb->data;
> + curr_rxbuf->skb = skb;
> + curr_rxbuf->length = adpt->rxbuf_size;
> + curr_rxbuf->dma_addr = dma_map_single(adpt->netdev->dev.parent,
> +   skb_data,
> +   curr_rxbuf->length,
> +   DMA_FROM_DEVICE);


Mapping can fail. You should check the result via dma_mapping_error(). 
There are several other places in which dma_map_single() is called and the 
return value 
is not checked.

> +/* Bringup the interface/HW */
> +int emac_mac_up(struct emac_adapter *adpt)
> +{
> + struct net_device *netdev = adpt->netdev;
> + struct emac_irq *irq = >irq;
> + int ret;
> +
> + emac_mac_rx_tx_ring_reset_all(adpt);
> + emac_mac_config(adpt);
> +
> + ret = request_irq(irq->irq, emac_isr, 0, EMAC_MAC_IRQ_RES, irq);
> + if (ret) {
> + netdev_err(adpt->netdev,
> +"error:%d on request_irq(%d:%s flags:0)\n", ret,
> +irq->irq, EMAC_MAC_IRQ_RES);
> + return ret;
> + }
> +
> + emac_mac_rx_descs_refill(adpt, >rx_q);
> +
> + ret = phy_connect_direct(netdev, adpt->phydev, emac_adjust_link,
> +  PHY_INTERFACE_MODE_SGMII);
> + if (ret) {
> + netdev_err(adpt->netdev,
> +"error:%d on request_irq(%d:%s flags:0)\n", ret,
> +irq->irq, EMAC_MAC_IRQ_RES);

freeing the irq is missing


> +
> +/* Bring down the interface/HW */
> +void emac_mac_down(struct emac_adapter *adpt, bool reset)
> +{
> + struct net_device *netdev = adpt->netdev;
> + unsigned long flags;
> +
> + netif_stop_queue(netdev);
> + napi_disable(>rx_q.napi);
> +
> + phy_disconnect(adpt->phydev);
> +
> + /* disable mac irq */
> + writel(DIS_INT, adpt->base + EMAC_INT_STATUS);
> + writel(0, adpt->base + EMAC_INT_MASK);
> + synchronize_irq(adpt->irq.irq);
> + free_irq(adpt->irq.irq, >irq);
> + clear_bit(EMAC_STATUS_TASK_REINIT_REQ, >status);
> +
> + cancel_work_sync(>tx_ts_task);
> + spin_lock_irqsave(>tx_ts_lock, flags);

Maybe I am missing something but AFAICS tx_ts_lock is never called from irq 
context, so 
there is no reason to disable irqs. 

> +
> +/* Push the received skb to upper layers */
> +static void emac_receive_skb(struct emac_rx_queue *rx_q,
> +  struct sk_buff *skb,
> +  u16 vlan_tag, bool vlan_flag)
> +{
> + if (vlan_flag) {
> + u16 vlan;
> +
> + EMAC_TAG_TO_VLAN(vlan_tag, vlan);
> + __vlan_hwaccel_put_tag(skb, htons(ETH_P_8021Q), vlan);
> + }
> +
> + napi_gro_receive(_q->napi, skb);

napi_gro_receive requires rx checksum offload. However emac_receive_skb() is 
also called if
hardware checksumming is disabled. 

> +
> +/* Transmit the packet using specified transmit queue */
> +int emac_mac_tx_buf_send(struct emac_adapter *adpt, struct emac_tx_queue 
> *tx_q,
> +  struct sk_buff *skb)
> +{
> + struct emac_tpd tpd;
> + u32 prod_idx;
> +
> + if (!emac_tx_has_enough_descs(tx_q, skb)) {

Drivers should avoid this situation right from the start by checking after each 
transmission if the max number
 of possible descriptors is still available for a further transmission and stop 
the queue if there are not.
Furthermore there does not seem to be any function that wakes the queue up 
again once it has been stopped.

> +
> +/* reinitialize */
> +void emac_reinit_locked(struct emac_adapter *adpt)
> +{
> + while 

Re: [PATCH net-next V2 02/10] liquidio: Macro replacements

2016-07-03 Thread Joe Perches
On Sun, 2016-07-03 at 13:56 -0700, Raghu Vatsavayi wrote:
> This patch has minor replacements of ACCESS_ONCE macros with
> WRITE_ONCE and replacement of BUG_ON with polite version WARN_ON.

And makes some functions static.
> diff --git a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c 
> b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
[]
> @@ -547,14 +537,14 @@ static void lio_cn6xxx_get_pcie_qlmport(struct 
> octeon_device *oct)
>   dev_dbg(>pci_dev->dev, "Using PCIE Port %d\n", oct->pcie_port);
>  }
>  
> -void
> +static void
[]
> -int lio_cn6xxx_process_droq_intr_regs(struct octeon_device *oct)
> +static int lio_cn6xxx_process_droq_intr_regs(struct octeon_device *oct)

etc


Re: [PATCH net-next 00/10] NCSI Support

2016-07-03 Thread Or Gerlitz
On Sun, Jul 3, 2016 at 8:32 AM, Gavin Shan  wrote:
> This series rebases on David's linux-net git repo ("master" branch). It's
> to support NCSI stack on net/farady/ftgmac100.c
>
> The following figure gives an example about how NCSI is deployed: The NCSI is
> specified by DSP0222, which can be downloaded from the following link here
> (http://www.dmtf.org/sites/default/files/standards/documents/DSP0222_1.0.0.pdf).
>
>* The NC-SI (aka NCSI) is defined as the interface between a (Base) 
> Management
>  Controller (BMC) and one or multiple Network Controlers (NC) on host 
> side.
>  The interface is responsible for providing external network connectivity
>  for BMC.
>* Each BMC can connect to multiple packages, up to 8. Each package can have
>  multiple channels, up to 32. Every package and channel are identified by
>  3-bits and 5-bits in NCSI packet. At one moment, one channel is active to
>  provide service.
>* NCSI packet, encapsulated in ethernet frame, has 0x88F8 in the protocol
>  field. The destination MAC address should be 0xFF's while the source MAC
>  address can be arbitrary one.
>* NCSI packets are classified to command, response, AEN (Asynchronous Event
>  Notification). Commands are sent from BMC to host for configuration and
>  information retrival. Responses, corresponding to commands, are sent from
>  host to BMC for confirmation and requested information. One command 
> should
>  have one and only one response. AEN is sent from host to BMC for 
> notification
>  (e.g. link down on active channel) so that BMC can take appropriate 
> action.
>
>+--+
> +--+
>|  || Host 
> |
>|BMC   ||  
> |
>|  || +---+  +---+ 
> |
>|+-+   || | Package-A |  | Package-B | 
> |
>|| |   || +-+-+  +---+ 
> |
>||   NIC   |   || | Channel | Channel |  | Channel | Channel | 
> |
>++++---+
> +-+-+-+--+-+-+-+
>  | |  |
>  | |  |
>  +-+--+
>
> The design for the patchset is highlighted as below:
>
>* The NCSI interface is abstracted with "struct ncsi_dev". It's registered
>  when net_device is created, started to work by calling ncsi_start_dev()
>  when net_device is opened (ndo_open()). For the first time, NCSI packets
>  are sent and received to/from the far end (host in above figure) to probe
>  available NCSI packages and channels. After that, one channel is chosen 
> as
>  active one to provide service.
>* The NCSI stack is driven by workqueue and state machine internally.
>* AEN (Asychronous Event Notification) might be received from the far end
>  (host). The currently active NCSI channel fails over to another available
>  one if possible. Otherwise, the NCSI channel is out of service.
>* NCSI stack should be configurable through netlink or another mechanism,
>  but it's not implemented in this patchset. It's something TBD.
>* The first NIC driver that is aware of NCSI: 
> drivers/net/ethernet/faraday/ftgmac100.c


FWIW, talking to a colleague, he made a comment that some of the text
above is wrong:

AENs are sent from NIC to BMC. Not from Host to BMC.

The traffic between a BMC and a NIC is over RBT if it is formatted as
NC-SI packets. This is not over network traffic

Or.


[PATCH net-next V2 05/10] liquidio: iq/oq limits

2016-07-03 Thread Raghu Vatsavayi
This patch removes the dependency of number of iq/oq's on
number of cpus.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 6 +-
 1 file changed, 1 insertion(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 906d32e..a759cc9 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -3488,7 +3488,6 @@ static int setup_nic_devices(struct octeon_device 
*octeon_dev)
struct liquidio_if_cfg_resp *resp;
struct octdev_props *props;
int retval, num_iqueues, num_oqueues;
-   int num_cpus = num_online_cpus();
union oct_nic_if_cfg if_cfg;
unsigned int base_queue;
unsigned int gmx_port_id;
@@ -3530,10 +3529,7 @@ static int setup_nic_devices(struct octeon_device 
*octeon_dev)
gmx_port_id =
CFG_GET_GMXID_NIC_IF(octeon_get_conf(octeon_dev), i);
ifidx_or_pfnum = i;
-   if (num_iqueues > num_cpus)
-   num_iqueues = num_cpus;
-   if (num_oqueues > num_cpus)
-   num_oqueues = num_cpus;
+
dev_dbg(_dev->pci_dev->dev,
"requesting config for interface %d, iqs %d, oqs %d\n",
ifidx_or_pfnum, num_iqueues, num_oqueues);
-- 
1.8.3.1



[PATCH net-next V2 02/10] liquidio: Macro replacements

2016-07-03 Thread Raghu Vatsavayi
This patch has minor replacements of ACCESS_ONCE macros with
WRITE_ONCE and replacement of BUG_ON with polite version WARN_ON.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 .../net/ethernet/cavium/liquidio/cn66xx_device.c   | 16 +---
 .../net/ethernet/cavium/liquidio/cn66xx_device.h   |  2 -
 .../net/ethernet/cavium/liquidio/cn68xx_device.c   | 13 +---
 .../net/ethernet/cavium/liquidio/cn68xx_device.h   |  1 -
 drivers/net/ethernet/cavium/liquidio/lio_ethtool.c | 24 ++
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 58 +++
 .../net/ethernet/cavium/liquidio/octeon_console.c  | 35 +++--
 .../net/ethernet/cavium/liquidio/octeon_device.c   | 85 --
 .../net/ethernet/cavium/liquidio/octeon_device.h   |  3 +-
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 17 +
 drivers/net/ethernet/cavium/liquidio/octeon_droq.h | 17 +
 drivers/net/ethernet/cavium/liquidio/octeon_main.h |  2 +-
 .../net/ethernet/cavium/liquidio/octeon_mem_ops.c  | 24 ++
 .../net/ethernet/cavium/liquidio/octeon_network.h  |  2 +-
 drivers/net/ethernet/cavium/liquidio/octeon_nic.c  | 12 ---
 .../net/ethernet/cavium/liquidio/request_manager.c | 62 ++--
 .../ethernet/cavium/liquidio/response_manager.c| 14 
 17 files changed, 66 insertions(+), 321 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c 
b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
index d35864a..ee40b47 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
@@ -19,26 +19,16 @@
 * This file may also be available under a different license from Cavium.
 * Contact Cavium, Inc. for more information
 **/
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include "octeon_config.h"
 #include "liquidio_common.h"
 #include "octeon_droq.h"
 #include "octeon_iq.h"
 #include "response_manager.h"
 #include "octeon_device.h"
-#include "octeon_nic.h"
 #include "octeon_main.h"
-#include "octeon_network.h"
 #include "cn66xx_regs.h"
 #include "cn66xx_device.h"
-#include "liquidio_image.h"
-#include "octeon_mem_ops.h"
 
 int lio_cn6xxx_soft_reset(struct octeon_device *oct)
 {
@@ -547,14 +537,14 @@ static void lio_cn6xxx_get_pcie_qlmport(struct 
octeon_device *oct)
dev_dbg(>pci_dev->dev, "Using PCIE Port %d\n", oct->pcie_port);
 }
 
-void
+static void
 lio_cn6xxx_process_pcie_error_intr(struct octeon_device *oct, u64 intr64)
 {
dev_err(>pci_dev->dev, "Error Intr: 0x%016llx\n",
CVM_CAST64(intr64));
 }
 
-int lio_cn6xxx_process_droq_intr_regs(struct octeon_device *oct)
+static int lio_cn6xxx_process_droq_intr_regs(struct octeon_device *oct)
 {
struct octeon_droq *droq;
int oq_no;
@@ -579,7 +569,7 @@ int lio_cn6xxx_process_droq_intr_regs(struct octeon_device 
*oct)
continue;
 
droq = oct->droq[oq_no];
-   pkt_count = octeon_droq_check_hw_for_pkts(oct, droq);
+   pkt_count = octeon_droq_check_hw_for_pkts(droq);
if (pkt_count) {
oct->droq_intr |= (1ULL << oq_no);
if (droq->ops.poll_mode) {
diff --git a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.h 
b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.h
index fe2932c..28c4722 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.h
+++ b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.h
@@ -82,8 +82,6 @@ void lio_cn6xxx_setup_iq_regs(struct octeon_device *oct, u32 
iq_no);
 void lio_cn6xxx_setup_oq_regs(struct octeon_device *oct, u32 oq_no);
 void lio_cn6xxx_enable_io_queues(struct octeon_device *oct);
 void lio_cn6xxx_disable_io_queues(struct octeon_device *oct);
-void lio_cn6xxx_process_pcie_error_intr(struct octeon_device *oct, u64 intr64);
-int lio_cn6xxx_process_droq_intr_regs(struct octeon_device *oct);
 irqreturn_t lio_cn6xxx_process_interrupt_regs(void *dev);
 void lio_cn6xxx_reinit_regs(struct octeon_device *oct);
 void lio_cn6xxx_bar1_idx_setup(struct octeon_device *oct, u64 core_addr,
diff --git a/drivers/net/ethernet/cavium/liquidio/cn68xx_device.c 
b/drivers/net/ethernet/cavium/liquidio/cn68xx_device.c
index 8e830d0..29755bc 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn68xx_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/cn68xx_device.c
@@ -19,28 +19,17 @@
 * This file may also be available under a different license from Cavium.
 * Contact Cavium, Inc. for more information
 **/
-#include 
-#include 
-#include 
-#include 
 #include 
-#include 
 #include 
-#include 

[PATCH net-next V2 04/10] liquidio: softcommand delay

2016-07-03 Thread Raghu Vatsavayi
This patch updates the delay constant for softcommands in
accrodance with new requirements.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 2 +-
 drivers/net/ethernet/cavium/liquidio/request_manager.c  | 3 ++-
 drivers/net/ethernet/cavium/liquidio/response_manager.c | 5 ++---
 3 files changed, 5 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 3d229c0..906d32e 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -3555,7 +3555,7 @@ static int setup_nic_devices(struct octeon_device 
*octeon_dev)
 
sc->callback = if_cfg_callback;
sc->callback_arg = sc;
-   sc->wait_time = 1000;
+   sc->wait_time = 3000;
 
retval = octeon_send_soft_command(octeon_dev, sc);
if (retval == IQ_SEND_FAILED) {
diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c 
b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index ef0bdd8..3f7044c 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -523,9 +523,10 @@ static void check_db_timeout(struct work_struct *work)
struct octeon_device *oct = (struct octeon_device *)wk->ctxptr;
unsigned long iq_no = wk->ctxul;
struct cavium_wq *db_wq = >check_db_wq[iq_no];
+   u32 delay = 10;
 
__check_db_timeout(oct, iq_no);
-   queue_delayed_work(db_wq->wq, _wq->wk.work, msecs_to_jiffies(1));
+   queue_delayed_work(db_wq->wq, _wq->wk.work, msecs_to_jiffies(delay));
 }
 
 int
diff --git a/drivers/net/ethernet/cavium/liquidio/response_manager.c 
b/drivers/net/ethernet/cavium/liquidio/response_manager.c
index 0cc2f66..709049e 100644
--- a/drivers/net/ethernet/cavium/liquidio/response_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/response_manager.c
@@ -52,7 +52,7 @@ int octeon_setup_response_list(struct octeon_device *oct)
INIT_DELAYED_WORK(>wk.work, oct_poll_req_completion);
cwq->wk.ctxptr = oct;
oct->cmd_resp_state = OCT_DRV_ONLINE;
-   queue_delayed_work(cwq->wq, >wk.work, msecs_to_jiffies(100));
+   queue_delayed_work(cwq->wq, >wk.work, msecs_to_jiffies(50));
 
return ret;
 }
@@ -162,6 +162,5 @@ static void oct_poll_req_completion(struct work_struct 
*work)
struct cavium_wq *cwq = >dma_comp_wq;
 
lio_process_ordered_list(oct, 0);
-
-   queue_delayed_work(cwq->wq, >wk.work, msecs_to_jiffies(100));
+   queue_delayed_work(cwq->wq, >wk.work, msecs_to_jiffies(50));
 }
-- 
1.8.3.1



[PATCH net-next V2 01/10] liquidio: Vxlan support

2016-07-03 Thread Raghu Vatsavayi
This patch adds support for Vxaln offloads in liquidio driver.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 drivers/net/ethernet/cavium/liquidio/lio_ethtool.c |  29 +++
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 208 -
 .../net/ethernet/cavium/liquidio/liquidio_common.h |  12 ++
 drivers/net/ethernet/cavium/liquidio/octeon_droq.h |   3 +
 drivers/net/ethernet/cavium/liquidio/octeon_iq.h   |   1 +
 .../net/ethernet/cavium/liquidio/octeon_network.h  |   6 +
 6 files changed, 254 insertions(+), 5 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c 
b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
index 03bfa97..a060586 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
@@ -106,6 +106,7 @@ static const char oct_stats_strings[][ETH_GSTRING_LEN] = {
"tx_tso",
"tx_tso_packets",
"tx_tso_err",
+   "tx_vxlan",
 
"mac_tx_total_pkts",
"mac_tx_total_bytes",
@@ -129,6 +130,9 @@ static const char oct_stats_strings[][ETH_GSTRING_LEN] = {
"rx_err_link",
"rx_err_drop",
 
+   "rx_vxlan",
+   "rx_vxlan_err",
+
"rx_lro_pkts",
"rx_lro_bytes",
"rx_total_lro",
@@ -167,6 +171,7 @@ static const char oct_iq_stats_strings[][ETH_GSTRING_LEN] = 
{
"fw_bytes_sent",
 
"tso",
+   "vxlan",
"txq_restart",
 };
 
@@ -186,6 +191,7 @@ static const char oct_droq_stats_strings[][ETH_GSTRING_LEN] 
= {
"fw_bytes_received",
"fw_dropped_nodispatch",
 
+   "vxlan",
"buffer_alloc_failure",
 };
 
@@ -675,6 +681,10 @@ lio_get_ethtool_stats(struct net_device *netdev,
 *fw_err_tso
 */
data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_err_tso);
+   /*per_core_stats[cvmx_get_core_num()].link_stats[idx].fromhost.
+*fw_tx_vxlan
+*/
+   data[i++] = CVM_CAST64(oct_dev->link_stats.fromhost.fw_tx_vxlan);
 
/* mac tx statistics */
/*CVMX_BGXX_CMRX_TX_STAT5 */
@@ -729,6 +739,15 @@ lio_get_ethtool_stats(struct net_device *netdev,
 */
data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_err_drop);
 
+   /*per_core_stats[cvmx_get_core_num()].link_stats[lro_ctx->ifidx].
+*fromwire.fw_rx_vxlan
+*/
+   data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_rx_vxlan);
+   /*per_core_stats[cvmx_get_core_num()].link_stats[lro_ctx->ifidx].
+*fromwire.fw_rx_vxlan_err
+*/
+   data[i++] = CVM_CAST64(oct_dev->link_stats.fromwire.fw_rx_vxlan_err);
+
/* LRO */
/*per_core_stats[cvmx_get_core_num()].link_stats[ifidx].fromwire.
 *fw_lro_pkts
@@ -822,6 +841,8 @@ lio_get_ethtool_stats(struct net_device *netdev,
 
/*tso request*/
data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_gso);
+   /*vxlan request*/
+   data[i++] = CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_vxlan);
/*txq restart*/
data[i++] =
CVM_CAST64(oct_dev->instr_queue[j]->stats.tx_restart);
@@ -858,6 +879,9 @@ lio_get_ethtool_stats(struct net_device *netdev,
CVM_CAST64(oct_dev->droq[j]->stats.bytes_received);
data[i++] =
CVM_CAST64(oct_dev->droq[j]->stats.dropped_nodispatch);
+
+   data[i++] =
+   CVM_CAST64(oct_dev->droq[j]->stats.rx_vxlan);
data[i++] =
CVM_CAST64(oct_dev->droq[j]->stats.rx_alloc_failure);
}
@@ -1083,6 +1107,9 @@ octnet_nic_stats_callback(struct octeon_device *oct_dev,
rstats->fw_err_pko = rsp_rstats->fw_err_pko;
rstats->fw_err_link = rsp_rstats->fw_err_link;
rstats->fw_err_drop = rsp_rstats->fw_err_drop;
+   rstats->fw_rx_vxlan = rsp_rstats->fw_rx_vxlan;
+   rstats->fw_rx_vxlan_err = rsp_rstats->fw_rx_vxlan_err;
+
/* Number of packets that are LROed  */
rstats->fw_lro_pkts = rsp_rstats->fw_lro_pkts;
/* Number of octets that are LROed   */
@@ -1127,6 +1154,8 @@ octnet_nic_stats_callback(struct octeon_device *oct_dev,
tstats->fw_tso = rsp_tstats->fw_tso;
tstats->fw_tso_fwd = rsp_tstats->fw_tso_fwd;
tstats->fw_err_tso = rsp_tstats->fw_err_tso;
+   tstats->fw_tx_vxlan = rsp_tstats->fw_tx_vxlan;
+
resp->status = 1;
} else {
resp->status = -1;
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index 1a584eb..4a5629f 

[PATCH net-next V2 10/10] liquidio: Response header changes

2016-07-03 Thread Raghu Vatsavayi
This patch changes response header to be able to communicate
with new firmware interface.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 drivers/net/ethernet/cavium/liquidio/liquidio_common.h | 18 --
 1 file changed, 12 insertions(+), 6 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/liquidio_common.h 
b/drivers/net/ethernet/cavium/liquidio/liquidio_common.h
index 603d205..199a8b9 100644
--- a/drivers/net/ethernet/cavium/liquidio/liquidio_common.h
+++ b/drivers/net/ethernet/cavium/liquidio/liquidio_common.h
@@ -542,6 +542,7 @@ union octeon_rh {
u64 csum_verified:3; /** checksum verified. */
u64 has_hwtstamp:1;  /** Has hardware timestamp. 1 = yes. */
u64 encap_on:1;
+   u64 has_hash:1;  /** Has hash (rth or rss). 1 = yes. */
} r_dh;
struct {
u64 opcode:4;
@@ -551,7 +552,8 @@ union octeon_rh {
u64 num_gmx_ports:8;
u64 max_nic_ports:10;
u64 app_cap_flags:4;
-   u64 app_mode:16;
+   u64 app_mode:8;
+   u64 pkind:8;
} r_core_drv_init;
struct {
u64 opcode:4;
@@ -571,6 +573,7 @@ union octeon_rh {
u64 opcode:4;
} r;
struct {
+   u64 has_hash:1;  /** Has hash (rth or rss). 1 = yes. */
u64 encap_on:1;
u64 has_hwtstamp:1;  /** 1 = has hwtstamp */
u64 csum_verified:3; /** checksum verified. */
@@ -582,7 +585,8 @@ union octeon_rh {
u64 opcode:4;
} r_dh;
struct {
-   u64 app_mode:16;
+   u64 pkind:8;
+   u64 app_mode:8;
u64 app_cap_flags:4;
u64 max_nic_ports:10;
u64 num_gmx_ports:8;
@@ -640,9 +644,11 @@ union oct_link_status {
u64 autoneg:1;
u64 if_mode:5;
u64 pause:1;
-   u64 reserved:16;
+   u64 flashing:1;
+   u64 reserved:15;
 #else
-   u64 reserved:16;
+   u64 reserved:15;
+   u64 flashing:1;
u64 pause:1;
u64 if_mode:5;
u64 autoneg:1;
@@ -869,9 +875,9 @@ union oct_nic_if_cfg {
u64 num_iqueues:16;
u64 num_oqueues:16;
u64 gmx_port_id:8;
-   u64 reserved:8;
+   u64 vf_id:8;
 #else
-   u64 reserved:8;
+   u64 vf_id:8;
u64 gmx_port_id:8;
u64 num_oqueues:16;
u64 num_iqueues:16;
-- 
1.8.3.1



[PATCH net-next V2 08/10] liquidio: Droq validation

2016-07-03 Thread Raghu Vatsavayi
This patch removes redudant droq num validation.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 12 
 1 file changed, 12 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c 
b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
index 8bfbe8c..93ab4ec 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_droq.c
@@ -821,18 +821,6 @@ octeon_process_droq_poll_cmd(struct octeon_device *oct, 
u32 q_no, int cmd,
 u32 arg)
 {
struct octeon_droq *droq;
-   struct octeon_config *oct_cfg = NULL;
-
-   oct_cfg = octeon_get_conf(oct);
-
-   if (!oct_cfg)
-   return -EINVAL;
-
-   if (q_no >= CFG_GET_OQ_MAX_Q(oct_cfg)) {
-   dev_err(>pci_dev->dev, "%s: droq id (%d) exceeds MAX 
(%d)\n",
-   __func__, q_no, (oct->num_oqs - 1));
-   return -EINVAL;
-   }
 
droq = oct->droq[q_no];
 
-- 
1.8.3.1



[PATCH net-next V2 09/10] liquidio: Remove redundant code

2016-07-03 Thread Raghu Vatsavayi
This patch removes redundant file includes and conditions.
Provides some meaningful comments and code alignment.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 .../net/ethernet/cavium/liquidio/cn66xx_device.c   |  2 +-
 drivers/net/ethernet/cavium/liquidio/cn68xx_regs.h |  1 -
 drivers/net/ethernet/cavium/liquidio/lio_ethtool.c | 18 ++-
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 26 +++---
 .../net/ethernet/cavium/liquidio/liquidio_common.h |  5 +++--
 .../net/ethernet/cavium/liquidio/octeon_config.h   |  4 ++--
 .../net/ethernet/cavium/liquidio/octeon_console.c  | 12 +-
 .../net/ethernet/cavium/liquidio/octeon_device.c   |  4 ++--
 .../net/ethernet/cavium/liquidio/octeon_device.h   |  4 ++--
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c | 13 ---
 drivers/net/ethernet/cavium/liquidio/octeon_iq.h   |  2 +-
 .../net/ethernet/cavium/liquidio/octeon_network.h  |  1 -
 .../net/ethernet/cavium/liquidio/request_manager.c |  6 +++--
 13 files changed, 51 insertions(+), 47 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c 
b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
index 6271c57..c03d370 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
@@ -219,7 +219,7 @@ void lio_cn6xxx_setup_global_output_regs(struct 
octeon_device *oct)
/* / Select Packet count instead of bytes for SLI_PKTi_CNTS[CNT] */
octeon_write_csr(oct, CN6XXX_SLI_PKT_OUT_BMODE, 0);
 
-   /* / Select ES,RO,NS setting from register for Output Queue Packet
+   /* Select ES, RO, NS setting from register for Output Queue Packet
 * Address
 */
octeon_write_csr(oct, CN6XXX_SLI_PKT_DPADDR, 0x);
diff --git a/drivers/net/ethernet/cavium/liquidio/cn68xx_regs.h 
b/drivers/net/ethernet/cavium/liquidio/cn68xx_regs.h
index 38cddbd..d45a0f4 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn68xx_regs.h
+++ b/drivers/net/ethernet/cavium/liquidio/cn68xx_regs.h
@@ -29,7 +29,6 @@
 
 #ifndef __CN68XX_REGS_H__
 #define __CN68XX_REGS_H__
-#include "cn66xx_regs.h"
 
 /*## REQUEST QUEUE #*/
 
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c 
b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
index 82f20c9..289eb89 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
@@ -464,18 +464,16 @@ static int lio_set_phys_id(struct net_device *netdev,
 
/* Configure Beacon values */
value = LIO68XX_LED_BEACON_CFGON;
-   ret =
-   octnet_mdio45_access(lio, 1,
-LIO68XX_LED_BEACON_ADDR,
-);
+   ret = octnet_mdio45_access(lio, 1,
+  LIO68XX_LED_BEACON_ADDR,
+  );
if (ret)
return ret;
 
value = LIO68XX_LED_CTRL_CFGON;
-   ret =
-   octnet_mdio45_access(lio, 1,
-LIO68XX_LED_CTRL_ADDR,
-);
+   ret = octnet_mdio45_access(lio, 1,
+  LIO68XX_LED_CTRL_ADDR,
+  );
if (ret)
return ret;
} else {
@@ -961,7 +959,6 @@ static int lio_get_intr_coalesce(struct net_device *netdev,
intr_coal->rx_max_coalesced_frames =
CFG_GET_OQ_INTR_PKT(cn6xxx->conf);
}
-
iq = oct->instr_queue[lio->linfo.txpciq[0].s.q_no];
intr_coal->tx_max_coalesced_frames = iq->fill_threshold;
break;
@@ -1688,13 +1685,12 @@ static void lio_get_regs(struct net_device *dev,
int len = 0;
struct octeon_device *oct = lio->oct_dev;
 
-   memset(regbuf, 0, OCT_ETHTOOL_REGDUMP_LEN);
regs->version = OCT_ETHTOOL_REGSVER;
 
switch (oct->chip_id) {
-   /* case OCTEON_CN73XX: Todo */
case OCTEON_CN68XX:
case OCTEON_CN66XX:
+   memset(regbuf, 0, OCT_ETHTOOL_REGDUMP_LEN);
len += cn6xxx_read_csr_reg(regbuf + len, oct);
len += cn6xxx_read_config_reg(regbuf + len, oct);
break;
diff --git 

[PATCH net-next V2 07/10] liquidio: MTU limits

2016-07-03 Thread Raghu Vatsavayi
This patch limits the MTU  between 68 bytes and 16000 bytes.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 drivers/net/ethernet/cavium/liquidio/lio_ethtool.c  |  2 +-
 drivers/net/ethernet/cavium/liquidio/lio_main.c | 21 +++--
 .../net/ethernet/cavium/liquidio/octeon_network.h   |  3 +++
 3 files changed, 15 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c 
b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
index 0f29dc4..82f20c9 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_ethtool.c
@@ -554,7 +554,7 @@ lio_ethtool_get_ringparam(struct net_device *netdev,
tx_pending = CFG_GET_NUM_TX_DESCS_NIC_IF(conf6x, lio->ifidx);
}
 
-   if (lio->mtu > OCTNET_DEFAULT_FRM_SIZE) {
+   if (lio->mtu > OCTNET_DEFAULT_FRM_SIZE - OCTNET_FRM_HEADER_SIZE) {
ering->rx_pending = 0;
ering->rx_max_pending = 0;
ering->rx_mini_pending = 0;
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index e4e476f..c75734f 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -2365,11 +2365,14 @@ void liquidio_link_ctrl_cmd_completion(void *nctrl_ptr)
case OCTNET_CMD_CHANGE_MTU:
/* If command is successful, change the MTU. */
netif_info(lio, probe, lio->netdev, " MTU Changed from %d to 
%d\n",
-  netdev->mtu, nctrl->ncmd.s.param2);
+  netdev->mtu, nctrl->ncmd.s.param1);
dev_info(>pci_dev->dev, "%s MTU Changed from %d to %d\n",
 netdev->name, netdev->mtu,
-nctrl->ncmd.s.param2);
-   netdev->mtu = nctrl->ncmd.s.param2;
+nctrl->ncmd.s.param1);
+   rtnl_lock();
+   netdev->mtu = nctrl->ncmd.s.param1;
+   call_netdevice_notifiers(NETDEV_CHANGEMTU, netdev);
+   rtnl_unlock();
break;
 
case OCTNET_CMD_GPIO_ACCESS:
@@ -2657,18 +2660,16 @@ static int liquidio_change_mtu(struct net_device 
*netdev, int new_mtu)
struct lio *lio = GET_LIO(netdev);
struct octeon_device *oct = lio->oct_dev;
struct octnic_ctrl_pkt nctrl;
-   int max_frm_size = new_mtu + OCTNET_FRM_HEADER_SIZE;
int ret = 0;
 
-   /* Limit the MTU to make sure the ethernet packets are between 64 bytes
-* and 65535 bytes
+   /* Limit the MTU to make sure the ethernet packets are between 68 bytes
+* and 16000 bytes
 */
-   if ((max_frm_size < OCTNET_MIN_FRM_SIZE) ||
-   (max_frm_size > OCTNET_MAX_FRM_SIZE)) {
+   if ((new_mtu < LIO_MIN_MTU_SIZE) ||
+   (new_mtu > LIO_MAX_MTU_SIZE)) {
dev_err(>pci_dev->dev, "Invalid MTU: %d\n", new_mtu);
dev_err(>pci_dev->dev, "Valid range %d and %d\n",
-   (OCTNET_MIN_FRM_SIZE - OCTNET_FRM_HEADER_SIZE),
-   (OCTNET_MAX_FRM_SIZE - OCTNET_FRM_HEADER_SIZE));
+   LIO_MIN_MTU_SIZE, LIO_MAX_MTU_SIZE);
return -EINVAL;
}
 
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_network.h 
b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
index 5d89f55..ab41866 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_network.h
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_network.h
@@ -30,6 +30,9 @@
 #include 
 #include 
 
+#define LIO_MAX_MTU_SIZE (OCTNET_MAX_FRM_SIZE - OCTNET_FRM_HEADER_SIZE)
+#define LIO_MIN_MTU_SIZE 68
+
 struct oct_nic_stats_resp {
u64 rh;
struct oct_link_stats stats;
-- 
1.8.3.1



[PATCH net-next V2 03/10] liquidio: IQ synchronization

2016-07-03 Thread Raghu Vatsavayi
This patch tries to protect against bh preemption with
sc_buf_pool. It also modifies the syncronization primitives
during input queue processing.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 .../net/ethernet/cavium/liquidio/request_manager.c | 27 +-
 1 file changed, 16 insertions(+), 11 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/request_manager.c 
b/drivers/net/ethernet/cavium/liquidio/request_manager.c
index 5e2211f..ef0bdd8 100644
--- a/drivers/net/ethernet/cavium/liquidio/request_manager.c
+++ b/drivers/net/ethernet/cavium/liquidio/request_manager.c
@@ -360,6 +360,7 @@ lio_process_iq_request_list(struct octeon_device *oct,
unsigned int pkts_compl = 0, bytes_compl = 0;
struct octeon_soft_command *sc;
struct octeon_instr_irh *irh;
+   unsigned long flags;
 
while (old != iq->octeon_read_index) {
reqtype = iq->request_list[old].reqtype;
@@ -389,15 +390,19 @@ lio_process_iq_request_list(struct octeon_device *oct,
 * command response list because we expect
 * a response from Octeon.
 */
-   spin_lock_bh(>response_list
-   [OCTEON_ORDERED_SC_LIST].lock);
+   spin_lock_irqsave
+   (>response_list
+[OCTEON_ORDERED_SC_LIST].lock,
+flags);
atomic_inc(>response_list
[OCTEON_ORDERED_SC_LIST].
pending_req_count);
list_add_tail(>node, >response_list
[OCTEON_ORDERED_SC_LIST].head);
-   spin_unlock_bh(>response_list
-   [OCTEON_ORDERED_SC_LIST].lock);
+   spin_unlock_irqrestore
+   (>response_list
+[OCTEON_ORDERED_SC_LIST].lock,
+flags);
} else {
if (sc->callback) {
sc->callback(oct, OCTEON_REQUEST_DONE,
@@ -674,7 +679,7 @@ int octeon_free_sc_buffer_pool(struct octeon_device *oct)
struct list_head *tmp, *tmp2;
struct octeon_soft_command *sc;
 
-   spin_lock(>sc_buf_pool.lock);
+   spin_lock_bh(>sc_buf_pool.lock);
 
list_for_each_safe(tmp, tmp2, >sc_buf_pool.head) {
list_del(tmp);
@@ -686,7 +691,7 @@ int octeon_free_sc_buffer_pool(struct octeon_device *oct)
 
INIT_LIST_HEAD(>sc_buf_pool.head);
 
-   spin_unlock(>sc_buf_pool.lock);
+   spin_unlock_bh(>sc_buf_pool.lock);
 
return 0;
 }
@@ -705,10 +710,10 @@ struct octeon_soft_command 
*octeon_alloc_soft_command(struct octeon_device *oct,
WARN_ON((offset + datasize + rdatasize + ctxsize) >
   SOFT_COMMAND_BUFFER_SIZE);
 
-   spin_lock(>sc_buf_pool.lock);
+   spin_lock_bh(>sc_buf_pool.lock);
 
if (list_empty(>sc_buf_pool.head)) {
-   spin_unlock(>sc_buf_pool.lock);
+   spin_unlock_bh(>sc_buf_pool.lock);
return NULL;
}
 
@@ -719,7 +724,7 @@ struct octeon_soft_command 
*octeon_alloc_soft_command(struct octeon_device *oct,
 
atomic_inc(>sc_buf_pool.alloc_buf_count);
 
-   spin_unlock(>sc_buf_pool.lock);
+   spin_unlock_bh(>sc_buf_pool.lock);
 
sc = (struct octeon_soft_command *)tmp;
 
@@ -762,11 +767,11 @@ struct octeon_soft_command 
*octeon_alloc_soft_command(struct octeon_device *oct,
 void octeon_free_soft_command(struct octeon_device *oct,
  struct octeon_soft_command *sc)
 {
-   spin_lock(>sc_buf_pool.lock);
+   spin_lock_bh(>sc_buf_pool.lock);
 
list_add_tail(>node, >sc_buf_pool.head);
 
atomic_dec(>sc_buf_pool.alloc_buf_count);
 
-   spin_unlock(>sc_buf_pool.lock);
+   spin_unlock_bh(>sc_buf_pool.lock);
 }
-- 
1.8.3.1



[PATCH net-next V2 06/10] liquidio: free resources during shutdown

2016-07-03 Thread Raghu Vatsavayi
This patch fixes the issue of proper freeing of queue
memory resources during free device. It also has fix for
correct pcie error reporting.

Signed-off-by: Derek Chickles 
Signed-off-by: Satanand Burla 
Signed-off-by: Felix Manlunas 
Signed-off-by: Raghu Vatsavayi 
---
 drivers/net/ethernet/cavium/liquidio/cn66xx_device.c  |  4 ++--
 drivers/net/ethernet/cavium/liquidio/lio_main.c   |  4 +++-
 drivers/net/ethernet/cavium/liquidio/octeon_console.c |  3 +++
 drivers/net/ethernet/cavium/liquidio/octeon_device.c  | 10 +-
 4 files changed, 13 insertions(+), 8 deletions(-)

diff --git a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c 
b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
index ee40b47..6271c57 100644
--- a/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/cn66xx_device.c
@@ -64,9 +64,9 @@ void lio_cn6xxx_enable_error_reporting(struct octeon_device 
*oct)
u32 val;
 
pci_read_config_dword(oct->pci_dev, CN6XXX_PCIE_DEVCTL, );
-   if (val & 0x000f) {
+   if (val & 0x000c) {
dev_err(>pci_dev->dev, "PCI-E Link error detected: 
0x%08x\n",
-   val & 0x000f);
+   val & 0x000c);
}
 
val |= 0xf;  /* Enable Link error reporting */
diff --git a/drivers/net/ethernet/cavium/liquidio/lio_main.c 
b/drivers/net/ethernet/cavium/liquidio/lio_main.c
index a759cc9..e4e476f 100644
--- a/drivers/net/ethernet/cavium/liquidio/lio_main.c
+++ b/drivers/net/ethernet/cavium/liquidio/lio_main.c
@@ -3957,6 +3957,7 @@ static int octeon_device_init(struct octeon_device 
*octeon_dev)
/* Release any previously allocated queues */
for (j = 0; j < octeon_dev->num_oqs; j++)
octeon_delete_droq(octeon_dev, j);
+   return 1;
}
 
atomic_set(_dev->status, OCT_DEV_DROQ_INIT_DONE);
@@ -3979,7 +3980,8 @@ static int octeon_device_init(struct octeon_device 
*octeon_dev)
 
/* Setup the interrupt handler and record the INT SUM register address
 */
-   octeon_setup_interrupt(octeon_dev);
+   if (octeon_setup_interrupt(octeon_dev))
+   return 1;
 
/* Enable Octeon device interrupts */
octeon_dev->fn_list.enable_interrupt(octeon_dev->chip);
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_console.c 
b/drivers/net/ethernet/cavium/liquidio/octeon_console.c
index bceff8a..70a8cd3 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_console.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_console.c
@@ -312,6 +312,9 @@ static u64 cvmx_bootmem_phy_named_block_find(struct 
octeon_device *oct,
if (name && named_size) {
char *name_tmp =
kmalloc(name_length + 1, GFP_KERNEL);
+   if (!name_tmp)
+   break;
+
CVMX_BOOTMEM_NAMED_GET_NAME(oct, named_addr,
name_tmp,
name_length);
diff --git a/drivers/net/ethernet/cavium/liquidio/octeon_device.c 
b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
index 046f096..fda93be 100644
--- a/drivers/net/ethernet/cavium/liquidio/octeon_device.c
+++ b/drivers/net/ethernet/cavium/liquidio/octeon_device.c
@@ -644,16 +644,16 @@ int octeon_download_firmware(struct octeon_device *oct, 
const u8 *data,
 
 void octeon_free_device_mem(struct octeon_device *oct)
 {
-   u32 i;
+   int i;
 
for (i = 0; i < MAX_OCTEON_OUTPUT_QUEUES(oct); i++) {
-   /* could check  mask as well */
-   vfree(oct->droq[i]);
+   if (oct->io_qmask.oq & (1ULL << i))
+   vfree(oct->droq[i]);
}
 
for (i = 0; i < MAX_OCTEON_INSTR_QUEUES(oct); i++) {
-   /* could check mask as well */
-   vfree(oct->instr_queue[i]);
+   if (oct->io_qmask.iq & (1ULL << i))
+   vfree(oct->instr_queue[i]);
}
 
i = oct->octeon_id;
-- 
1.8.3.1



[PATCH net-next V2 00/10] liquidio updates and bug fixes

2016-07-03 Thread Raghu Vatsavayi
Dave,

Following V2 patchset contains updates and bug fixes for
liquidio driver. This patchset also has changes that you
suggested in vxlan code. Please apply the patches in following
order as some of the patches depend on earlier patches in the
series.

Raghu Vatsavayi (10):
  liquidio: Vxlan support
  liquidio: Macro replacements
  liquidio: IQ synchronization
  liquidio: softcommand delay
  liquidio: iq/oq limits
  liquidio: free resources during shutdown
  liquidio: MTU limits
  liquidio: Droq validation
  liquidio: Remove redundant code
  liquidio: Response header changes

 .../net/ethernet/cavium/liquidio/cn66xx_device.c   |  22 +-
 .../net/ethernet/cavium/liquidio/cn66xx_device.h   |   2 -
 .../net/ethernet/cavium/liquidio/cn68xx_device.c   |  13 +-
 .../net/ethernet/cavium/liquidio/cn68xx_device.h   |   1 -
 drivers/net/ethernet/cavium/liquidio/cn68xx_regs.h |   1 -
 drivers/net/ethernet/cavium/liquidio/lio_ethtool.c |  73 +++--
 drivers/net/ethernet/cavium/liquidio/lio_main.c| 325 -
 .../net/ethernet/cavium/liquidio/liquidio_common.h |  35 ++-
 .../net/ethernet/cavium/liquidio/octeon_config.h   |   4 +-
 .../net/ethernet/cavium/liquidio/octeon_console.c  |  50 ++--
 .../net/ethernet/cavium/liquidio/octeon_device.c   |  99 +--
 .../net/ethernet/cavium/liquidio/octeon_device.h   |   7 +-
 drivers/net/ethernet/cavium/liquidio/octeon_droq.c |  42 +--
 drivers/net/ethernet/cavium/liquidio/octeon_droq.h |  20 +-
 drivers/net/ethernet/cavium/liquidio/octeon_iq.h   |   3 +-
 drivers/net/ethernet/cavium/liquidio/octeon_main.h |   2 +-
 .../net/ethernet/cavium/liquidio/octeon_mem_ops.c  |  24 +-
 .../net/ethernet/cavium/liquidio/octeon_network.h  |  12 +-
 drivers/net/ethernet/cavium/liquidio/octeon_nic.c  |  12 -
 .../net/ethernet/cavium/liquidio/request_manager.c |  98 ++-
 .../ethernet/cavium/liquidio/response_manager.c|  19 +-
 21 files changed, 433 insertions(+), 431 deletions(-)

-- 
1.8.3.1



[PATCH net,stable] cdc_ncm: workaround for EM7455 "silent" data interface

2016-07-03 Thread Bjørn Mork
Several Lenovo users have reported problems with their Sierra
Wireless EM7455 modem. The driver has loaded successfully and
the MBIM management channel has appeared to work, including
establishing a connection to the mobile network. But no frames
have been received over the data interface.

The problem affects all EM7455 and MC7455, and is assumed to
affect other modems based on the same Qualcomm chipset and
baseband firmware.

Testing narrowed the problem down to what seems to be a
firmware timing bug during initialization. Adding a short sleep
while probing is sufficient to make the problem disappear.
Experiments have shown that 1-2 ms is too little to have any
effect, while 10-20 ms is enough to reliably succeed.

Reported-by: Stefan Armbruster 
Reported-by: Ralph Plawetzki 
Reported-by: Andreas Fett 
Reported-by: Rasmus Lerdorf 
Reported-by: Samo Ratnik 
Reported-and-tested-by: Aleksander Morgado 
Signed-off-by: Bjørn Mork 
---
I hope this unconditional short sleep during probing is acceptable,
as I don't want to start a new non-maintainable quirk device list for
this.  The EM7455 is already used by a number of laptop vendors, each
using their own device ID.  More are likely to come.  And that's only
the modems we *know* are affected...

 drivers/net/usb/cdc_ncm.c | 7 +++
 1 file changed, 7 insertions(+)

diff --git a/drivers/net/usb/cdc_ncm.c b/drivers/net/usb/cdc_ncm.c
index 53759c315b97..877c9516e781 100644
--- a/drivers/net/usb/cdc_ncm.c
+++ b/drivers/net/usb/cdc_ncm.c
@@ -854,6 +854,13 @@ int cdc_ncm_bind_common(struct usbnet *dev, struct 
usb_interface *intf, u8 data_
if (cdc_ncm_init(dev))
goto error2;
 
+   /* Some firmwares need a pause here or they will silently fail
+* to set up the interface properly.  This value was decided
+* empirically on a Sierra Wireless MC7455 running 02.08.02.00
+* firmware.
+*/
+   usleep_range(1, 2);
+
/* configure data interface */
temp = usb_set_interface(dev->udev, iface_no, data_altsetting);
if (temp) {
-- 
2.1.4



Re: [PATCHv3 wl-drv-next 1/2] add basic register-field manipulation macros

2016-07-03 Thread Hannes Frederic Sowa
On 01.07.2016 23:26, Jakub Kicinski wrote:
> C bitfields are problematic and best avoided.  Developers
> interacting with hardware registers find themselves searching
> for easy-to-use alternatives.  Common approach is to define
> structures or sets of macros containing mask and shift pair.
> Operations on the register are then performed as follows:
> 
>  field = (reg >> shift) & mask;
> 
>  reg &= ~(mask << shift);
>  reg |= (field & mask) << shift;
> 
> Defining shift and mask separately is tedious.  Ivo van Doorn
> came up with an idea of computing them at compilation time
> based on a single shifted mask (later refined by Felix) which
> can be used like this:
> 
>  #define REG_FIELD 0x000ff000
> 
>  field = FIELD_GET(REG_FIELD, reg);
> 
>  reg &= ~REG_FIELD;
>  reg |= FIELD_PUT(REG_FIELD, field);
> 
> FIELD_{GET,PUT} macros take care of finding out what the
> appropriate shift is based on compilation time ffs operation.
> 
> GENMASK can be used to define registers (which is usually
> less error-prone and easier to match with datasheets).
> 
> This approach is the most convenient I've seen so to limit code
> multiplication let's move the macros to a global header file.
> 
> Signed-off-by: Jakub Kicinski 
> ---
>  include/linux/bitfield.h | 58 
> 
>  include/linux/bug.h  |  3 +++
>  2 files changed, 61 insertions(+)
>  create mode 100644 include/linux/bitfield.h
> 
> diff --git a/include/linux/bitfield.h b/include/linux/bitfield.h
> new file mode 100644
> index ..d6a36c3c1775
> --- /dev/null
> +++ b/include/linux/bitfield.h
> @@ -0,0 +1,58 @@
> +/*
> + * Copyright (C) 2014 Felix Fietkau 
> + * Copyright (C) 2004 - 2009 Ivo van Doorn 
> + *
> + * This program is free software; you can redistribute it and/or modify
> + * it under the terms of the GNU General Public License version 2
> + * as published by the Free Software Foundation
> + *
> + * This program is distributed in the hope that it will be useful,
> + * but WITHOUT ANY WARRANTY; without even the implied warranty of
> + * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
> + * GNU General Public License for more details.
> + */
> +
> +#ifndef _LINUX_BITFIELD_H
> +#define _LINUX_BITFIELD_H
> +
> +#include 
> +#include 
> +#include 
> +
> +#define _bf_shf(x) (__builtin_ffsll(x) - 1)
> +
> +#define _BF_FIELD_CHECK(_mask, _val) \
> + ({  \
> + BUILD_BUG_ON(!(_mask)); \
> + BUILD_BUG_ON(__builtin_constant_p(_val) ?   \
> +  ~((_mask) >> _bf_shf(_mask)) & (_val) :\
> +  0);\
> + __BUILD_BUG_ON_NOT_POWER_OF_2((_mask) + \
> +   (1ULL << _bf_shf(_mask))); \
> + })
> +
> +#define FIELD_PUT(_mask, _val)   \
> + ({  \
> + _BF_FIELD_CHECK(_mask, _val);   \
> + ((u32)(_val) << _bf_shf(_mask)) & (_mask);  \
> + })
> +
> +#define FIELD_GET(_mask, _val)   \
> + ({  \
> + _BF_FIELD_CHECK(_mask, 0);  \
> + (u32)(((_val) & (_mask)) >> _bf_shf(_mask));\
> + })
> +
> +#define FIELD_PUT64(_mask, _val) \
> + ({  \
> + _BF_FIELD_CHECK(_mask, _val);   \
> + ((u64)(_val) << _bf_shf(_mask)) & (_mask);  \
> + })
> +
> +#define FIELD_GET64(_mask, _val) \
> + ({  \
> + _BF_FIELD_CHECK(_mask, 0);  \
> + (u64)(((_val) & (_mask)) >> _bf_shf(_mask));\
> + })
> +
> +#endif

Cool! I think this is totally fine. Albeit one point: can you put your
commit comment into the header itself. People check header files more
often than git commits for documentation and it should be quickly
graspable by a developer if someone looks them up.

Thanks,
Hannes



Re: [PATCH] RDS: fix rds_tcp_init() error path

2016-07-03 Thread Santosh Shilimkar

On 7/3/2016 1:54 AM, Vegard Nossum wrote:

If register_pernet_subsys() fails, we shouldn't try to call
unregister_pernet_subsys().

Fixes: 467fa15356 ("RDS-TCP: Support multiple RDS-TCP listen endpoints, one per 
netns.")
Cc: sta...@vger.kernel.org
Cc: Sowmini Varadhan 
Cc: David S. Miller 
Signed-off-by: Vegard Nossum 
---

Acked-by: Santosh Shilimkar 


[PATCH 2/2] net: ethernet: bcmgenet: use phy_ethtool_{get|set}_link_ksettings

2016-07-03 Thread Philippe Reynes
There are two generics functions phy_ethtool_{get|set}_link_ksettings,
so we can use them instead of defining the same code in the driver.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c |   28 +--
 1 files changed, 2 insertions(+), 26 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c 
b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 8d4f849..76ed6df 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -450,30 +450,6 @@ static inline void bcmgenet_rdma_ring_writel(struct 
bcmgenet_priv *priv,
genet_dma_ring_regs[r]);
 }
 
-static int bcmgenet_get_settings(struct net_device *dev,
-struct ethtool_cmd *cmd)
-{
-   if (!netif_running(dev))
-   return -EINVAL;
-
-   if (!dev->phydev)
-   return -ENODEV;
-
-   return phy_ethtool_gset(dev->phydev, cmd);
-}
-
-static int bcmgenet_set_settings(struct net_device *dev,
-struct ethtool_cmd *cmd)
-{
-   if (!netif_running(dev))
-   return -EINVAL;
-
-   if (!dev->phydev)
-   return -ENODEV;
-
-   return phy_ethtool_sset(dev->phydev, cmd);
-}
-
 static int bcmgenet_set_rx_csum(struct net_device *dev,
netdev_features_t wanted)
 {
@@ -977,8 +953,6 @@ static struct ethtool_ops bcmgenet_ethtool_ops = {
.get_strings= bcmgenet_get_strings,
.get_sset_count = bcmgenet_get_sset_count,
.get_ethtool_stats  = bcmgenet_get_ethtool_stats,
-   .get_settings   = bcmgenet_get_settings,
-   .set_settings   = bcmgenet_set_settings,
.get_drvinfo= bcmgenet_get_drvinfo,
.get_link   = ethtool_op_get_link,
.get_msglevel   = bcmgenet_get_msglevel,
@@ -990,6 +964,8 @@ static struct ethtool_ops bcmgenet_ethtool_ops = {
.nway_reset = bcmgenet_nway_reset,
.get_coalesce   = bcmgenet_get_coalesce,
.set_coalesce   = bcmgenet_set_coalesce,
+   .get_link_ksettings = phy_ethtool_get_link_ksettings,
+   .set_link_ksettings = phy_ethtool_set_link_ksettings,
 };
 
 /* Power down the unimac, based on mode. */
-- 
1.7.4.4



[PATCH 1/2] net: ethernet: bcmgenet: use phydev from struct net_device

2016-07-03 Thread Philippe Reynes
The private structure contain a pointer to phydev, but the structure
net_device already contain such pointer. So we can remove the pointer
phy in the private structure, and update the driver to use the
one contained in struct net_device.

Signed-off-by: Philippe Reynes 
---
 drivers/net/ethernet/broadcom/genet/bcmgenet.c |   45 ++-
 drivers/net/ethernet/broadcom/genet/bcmgenet.h |1 -
 drivers/net/ethernet/broadcom/genet/bcmmii.c   |   24 ++---
 3 files changed, 31 insertions(+), 39 deletions(-)

diff --git a/drivers/net/ethernet/broadcom/genet/bcmgenet.c 
b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
index 5414563..8d4f849 100644
--- a/drivers/net/ethernet/broadcom/genet/bcmgenet.c
+++ b/drivers/net/ethernet/broadcom/genet/bcmgenet.c
@@ -453,29 +453,25 @@ static inline void bcmgenet_rdma_ring_writel(struct 
bcmgenet_priv *priv,
 static int bcmgenet_get_settings(struct net_device *dev,
 struct ethtool_cmd *cmd)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
-
if (!netif_running(dev))
return -EINVAL;
 
-   if (!priv->phydev)
+   if (!dev->phydev)
return -ENODEV;
 
-   return phy_ethtool_gset(priv->phydev, cmd);
+   return phy_ethtool_gset(dev->phydev, cmd);
 }
 
 static int bcmgenet_set_settings(struct net_device *dev,
 struct ethtool_cmd *cmd)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
-
if (!netif_running(dev))
return -EINVAL;
 
-   if (!priv->phydev)
+   if (!dev->phydev)
return -ENODEV;
 
-   return phy_ethtool_sset(priv->phydev, cmd);
+   return phy_ethtool_sset(dev->phydev, cmd);
 }
 
 static int bcmgenet_set_rx_csum(struct net_device *dev,
@@ -941,7 +937,7 @@ static int bcmgenet_get_eee(struct net_device *dev, struct 
ethtool_eee *e)
e->eee_active = p->eee_active;
e->tx_lpi_timer = bcmgenet_umac_readl(priv, UMAC_EEE_LPI_TIMER);
 
-   return phy_ethtool_get_eee(priv->phydev, e);
+   return phy_ethtool_get_eee(dev->phydev, e);
 }
 
 static int bcmgenet_set_eee(struct net_device *dev, struct ethtool_eee *e)
@@ -958,7 +954,7 @@ static int bcmgenet_set_eee(struct net_device *dev, struct 
ethtool_eee *e)
if (!p->eee_enabled) {
bcmgenet_eee_enable_set(dev, false);
} else {
-   ret = phy_init_eee(priv->phydev, 0);
+   ret = phy_init_eee(dev->phydev, 0);
if (ret) {
netif_err(priv, hw, dev, "EEE initialization failed\n");
return ret;
@@ -968,14 +964,12 @@ static int bcmgenet_set_eee(struct net_device *dev, 
struct ethtool_eee *e)
bcmgenet_eee_enable_set(dev, true);
}
 
-   return phy_ethtool_set_eee(priv->phydev, e);
+   return phy_ethtool_set_eee(dev->phydev, e);
 }
 
 static int bcmgenet_nway_reset(struct net_device *dev)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
-
-   return genphy_restart_aneg(priv->phydev);
+   return genphy_restart_aneg(dev->phydev);
 }
 
 /* standard ethtool support functions. */
@@ -1002,12 +996,13 @@ static struct ethtool_ops bcmgenet_ethtool_ops = {
 static int bcmgenet_power_down(struct bcmgenet_priv *priv,
enum bcmgenet_power_mode mode)
 {
+   struct net_device *ndev = priv->dev;
int ret = 0;
u32 reg;
 
switch (mode) {
case GENET_POWER_CABLE_SENSE:
-   phy_detach(priv->phydev);
+   phy_detach(ndev->phydev);
break;
 
case GENET_POWER_WOL_MAGIC:
@@ -1068,7 +1063,6 @@ static void bcmgenet_power_up(struct bcmgenet_priv *priv,
 /* ioctl handle special commands that are not present in ethtool. */
 static int bcmgenet_ioctl(struct net_device *dev, struct ifreq *rq, int cmd)
 {
-   struct bcmgenet_priv *priv = netdev_priv(dev);
int val = 0;
 
if (!netif_running(dev))
@@ -1078,10 +1072,10 @@ static int bcmgenet_ioctl(struct net_device *dev, 
struct ifreq *rq, int cmd)
case SIOCGMIIPHY:
case SIOCGMIIREG:
case SIOCSMIIREG:
-   if (!priv->phydev)
+   if (!dev->phydev)
val = -ENODEV;
else
-   val = phy_mii_ioctl(priv->phydev, rq, cmd);
+   val = phy_mii_ioctl(dev->phydev, rq, cmd);
break;
 
default:
@@ -2464,6 +2458,7 @@ static void bcmgenet_irq_task(struct work_struct *work)
 {
struct bcmgenet_priv *priv = container_of(
work, struct bcmgenet_priv, bcmgenet_irq_work);
+   struct net_device *ndev = priv->dev;
 
netif_dbg(priv, intr, priv->dev, "%s\n", __func__);
 
@@ -2476,7 +2471,7 @@ static void bcmgenet_irq_task(struct work_struct *work)
 
/* Link UP/DOWN event */
if (priv->irq0_stat & 

Re: [PATCH] RDS: fix rds_tcp_init() error path

2016-07-03 Thread Sowmini Varadhan

> If register_pernet_subsys() fails, we shouldn't try to call
> unregister_pernet_subsys().

Acked-by: Sowmini Varadhan 



Re: [PATCH 1/4] net: ethernet: ti: davinci_cpdma: split descs num between all channels

2016-07-03 Thread Ivan Khoronzhuk


On 01.07.16 23:35, David Miller wrote:

From: Ivan Khoronzhuk 
Date: Thu, 30 Jun 2016 22:04:35 +0300


@@ -720,7 +763,7 @@ unlock_ret:
  }
  EXPORT_SYMBOL_GPL(cpdma_chan_submit);

-bool cpdma_check_free_tx_desc(struct cpdma_chan *chan)
+inline bool cpdma_check_free_desc(struct cpdma_chan *chan)
  {


This needs to be marked static.


Yes. Will correct it.

--
Regards,
Ivan Khoronzhuk


[PATCH] RDS: fix rds_tcp_init() error path

2016-07-03 Thread Vegard Nossum
If register_pernet_subsys() fails, we shouldn't try to call
unregister_pernet_subsys().

Fixes: 467fa15356 ("RDS-TCP: Support multiple RDS-TCP listen endpoints, one per 
netns.")
Cc: sta...@vger.kernel.org
Cc: Sowmini Varadhan 
Cc: David S. Miller 
Signed-off-by: Vegard Nossum 
---
 net/rds/tcp.c | 5 +++--
 1 file changed, 3 insertions(+), 2 deletions(-)

diff --git a/net/rds/tcp.c b/net/rds/tcp.c
index 74ee126..c8a7b4c 100644
--- a/net/rds/tcp.c
+++ b/net/rds/tcp.c
@@ -616,7 +616,7 @@ static int rds_tcp_init(void)
 
ret = rds_tcp_recv_init();
if (ret)
-   goto out_slab;
+   goto out_pernet;
 
ret = rds_trans_register(_tcp_transport);
if (ret)
@@ -628,8 +628,9 @@ static int rds_tcp_init(void)
 
 out_recv:
rds_tcp_recv_exit();
-out_slab:
+out_pernet:
unregister_pernet_subsys(_tcp_net_ops);
+out_slab:
kmem_cache_destroy(rds_tcp_conn_slab);
 out:
return ret;
-- 
1.9.1