Merge git://git.kernel.org/pub/scm/linux/kernel/git/davem/net
[cascardo/linux.git] / drivers / net / ethernet / chelsio / cxgb4vf / sge.c
index cd5b789..50b1b34 100644 (file)
@@ -93,12 +93,6 @@ enum {
        TX_QCHECK_PERIOD = (HZ / 2),
        MAX_TIMER_TX_RECLAIM = 100,
 
-       /*
-        * An FL with <= FL_STARVE_THRES buffers is starving and a periodic
-        * timer will attempt to refill it.
-        */
-       FL_STARVE_THRES = 4,
-
        /*
         * Suspend an Ethernet TX queue with fewer available descriptors than
         * this.  We always want to have room for a maximum sized packet:
@@ -124,7 +118,7 @@ enum {
         * we can specify for immediate data in the firmware Ethernet TX
         * Work Request.
         */
-       MAX_IMM_TX_PKT_LEN = FW_WR_IMMDLEN_MASK,
+       MAX_IMM_TX_PKT_LEN = FW_WR_IMMDLEN_M,
 
        /*
         * Max size of a WR sent through a control TX queue.
@@ -604,6 +598,8 @@ static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl,
         */
        BUG_ON(fl->avail + n > fl->size - FL_PER_EQ_UNIT);
 
+       gfp |= __GFP_NOWARN;
+
        /*
         * If we support large pages, prefer large buffers and fail over to
         * small pages if we can't allocate large pages to satisfy the refill.
@@ -614,8 +610,7 @@ static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl,
                goto alloc_small_pages;
 
        while (n) {
-               page = alloc_pages(gfp | __GFP_COMP | __GFP_NOWARN,
-                                  s->fl_pg_order);
+               page = __dev_alloc_pages(gfp, s->fl_pg_order);
                if (unlikely(!page)) {
                        /*
                         * We've failed inour attempt to allocate a "large
@@ -659,7 +654,7 @@ static unsigned int refill_fl(struct adapter *adapter, struct sge_fl *fl,
 
 alloc_small_pages:
        while (n--) {
-               page = __skb_alloc_page(gfp | __GFP_NOWARN, NULL);
+               page = __dev_alloc_page(gfp);
                if (unlikely(!page)) {
                        fl->alloc_failed++;
                        break;
@@ -908,7 +903,7 @@ static void write_sgl(const struct sk_buff *skb, struct sge_txq *tq,
                sgl->addr0 = cpu_to_be64(addr[1]);
        }
 
-       sgl->cmd_nsge = htonl(ULPTX_CMD(ULP_TX_SC_DSGL) |
+       sgl->cmd_nsge = htonl(ULPTX_CMD_V(ULP_TX_SC_DSGL) |
                              ULPTX_NSGE(nfrags));
        if (likely(--nfrags == 0))
                return;
@@ -1151,7 +1146,7 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev)
                goto out_free;
        }
 
-       wr_mid = FW_WR_LEN16(DIV_ROUND_UP(flits, 2));
+       wr_mid = FW_WR_LEN16_V(DIV_ROUND_UP(flits, 2));
        if (unlikely(credits < ETHTXQ_STOP_THRES)) {
                /*
                 * After we're done injecting the Work Request for this
@@ -1163,7 +1158,7 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev)
                 * has opened up.
                 */
                txq_stop(txq);
-               wr_mid |= FW_WR_EQUEQ | FW_WR_EQUIQ;
+               wr_mid |= FW_WR_EQUEQ_F | FW_WR_EQUIQ_F;
        }
 
        /*
@@ -1193,9 +1188,9 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev)
                int eth_xtra_len = skb_network_offset(skb) - ETH_HLEN;
 
                wr->op_immdlen =
-                       cpu_to_be32(FW_WR_OP(FW_ETH_TX_PKT_VM_WR) |
-                                   FW_WR_IMMDLEN(sizeof(*lso) +
-                                                 sizeof(*cpl)));
+                       cpu_to_be32(FW_WR_OP_V(FW_ETH_TX_PKT_VM_WR) |
+                                   FW_WR_IMMDLEN_V(sizeof(*lso) +
+                                                   sizeof(*cpl)));
                /*
                 * Fill in the LSO CPL message.
                 */
@@ -1230,8 +1225,8 @@ int t4vf_eth_xmit(struct sk_buff *skb, struct net_device *dev)
 
                len = is_eth_imm(skb) ? skb->len + sizeof(*cpl) : sizeof(*cpl);
                wr->op_immdlen =
-                       cpu_to_be32(FW_WR_OP(FW_ETH_TX_PKT_VM_WR) |
-                                   FW_WR_IMMDLEN(len));
+                       cpu_to_be32(FW_WR_OP_V(FW_ETH_TX_PKT_VM_WR) |
+                                   FW_WR_IMMDLEN_V(len));
 
                /*
                 * Set up TX Packet CPL pointer, control word and perform
@@ -2093,10 +2088,10 @@ int t4vf_sge_alloc_rxq(struct adapter *adapter, struct sge_rspq *rspq,
         * into OS-independent common code ...
         */
        memset(&cmd, 0, sizeof(cmd));
-       cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP(FW_IQ_CMD) |
-                                   FW_CMD_REQUEST |
-                                   FW_CMD_WRITE |
-                                   FW_CMD_EXEC);
+       cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_IQ_CMD) |
+                                   FW_CMD_REQUEST_F |
+                                   FW_CMD_WRITE_F |
+                                   FW_CMD_EXEC_F);
        cmd.alloc_to_len16 = cpu_to_be32(FW_IQ_CMD_ALLOC |
                                         FW_IQ_CMD_IQSTART(1) |
                                         FW_LEN16(cmd));
@@ -2256,10 +2251,10 @@ int t4vf_sge_alloc_eth_txq(struct adapter *adapter, struct sge_eth_txq *txq,
         * into the common code ...
         */
        memset(&cmd, 0, sizeof(cmd));
-       cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP(FW_EQ_ETH_CMD) |
-                                   FW_CMD_REQUEST |
-                                   FW_CMD_WRITE |
-                                   FW_CMD_EXEC);
+       cmd.op_to_vfn = cpu_to_be32(FW_CMD_OP_V(FW_EQ_ETH_CMD) |
+                                   FW_CMD_REQUEST_F |
+                                   FW_CMD_WRITE_F |
+                                   FW_CMD_EXEC_F);
        cmd.alloc_to_len16 = cpu_to_be32(FW_EQ_ETH_CMD_ALLOC |
                                         FW_EQ_ETH_CMD_EQSTART |
                                         FW_LEN16(cmd));
@@ -2490,6 +2485,16 @@ int t4vf_sge_init(struct adapter *adapter)
                s->fl_align = max(ingpadboundary, ingpackboundary);
        }
 
+       /* A FL with <= fl_starve_thres buffers is starving and a periodic
+        * timer will attempt to refill it.  This needs to be larger than the
+        * SGE's Egress Congestion Threshold.  If it isn't, then we can get
+        * stuck waiting for new packets while the SGE is waiting for us to
+        * give it more Free List entries.  (Note that the SGE's Egress
+        * Congestion Threshold is in units of 2 Free List pointers.)
+        */
+       s->fl_starve_thres
+               = EGRTHRESHOLD_GET(sge_params->sge_congestion_control)*2 + 1;
+
        /*
         * Set up tasklet timers.
         */