These changes are the raw update to linux-4.4.6-rt14. Kernel sources
[kvmfornfv.git] / kernel / drivers / staging / octeon / ethernet-tx.c
index 5b9ac1f..c053c4a 100644 (file)
@@ -1,29 +1,13 @@
-/*********************************************************************
- * Author: Cavium Networks
- *
- * Contact: support@caviumnetworks.com
- * This file is part of the OCTEON SDK
+/*
+ * This file is based on code from OCTEON SDK by Cavium Networks.
  *
  * Copyright (c) 2003-2010 Cavium Networks
  *
  * This file 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 file is distributed in the hope that it will be useful, but
- * AS-IS and WITHOUT ANY WARRANTY; without even the implied warranty
- * of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE, TITLE, or
- * NONINFRINGEMENT.  See the GNU General Public License for more
- * details.
- *
- * You should have received a copy of the GNU General Public License
- * along with this file; if not, write to the Free Software
- * Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
- * or visit http://www.gnu.org/licenses/.
- *
- * This file may also be available under a different license from Cavium.
- * Contact Cavium Networks for more information
-*********************************************************************/
+ */
+
 #include <linux/module.h>
 #include <linux/kernel.h>
 #include <linux/netdevice.h>
@@ -159,8 +143,8 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
 {
        cvmx_pko_command_word0_t pko_command;
        union cvmx_buf_ptr hw_buffer;
-       uint64_t old_scratch;
-       uint64_t old_scratch2;
+       u64 old_scratch;
+       u64 old_scratch2;
        int qos;
        int i;
        enum {QUEUE_CORE, QUEUE_HW, QUEUE_DROP} queue_type;
@@ -411,11 +395,13 @@ int cvm_oct_xmit(struct sk_buff *skb, struct net_device *dev)
 dont_put_skbuff_in_hw:
 
        /* Check if we can use the hardware checksumming */
-       if (USE_HW_TCPUDP_CHECKSUM && (skb->protocol == htons(ETH_P_IP)) &&
-           (ip_hdr(skb)->version == 4) && (ip_hdr(skb)->ihl == 5) &&
-           ((ip_hdr(skb)->frag_off == 0) || (ip_hdr(skb)->frag_off == htons(1 << 14)))
-           && ((ip_hdr(skb)->protocol == IPPROTO_TCP)
-               || (ip_hdr(skb)->protocol == IPPROTO_UDP))) {
+       if ((skb->protocol == htons(ETH_P_IP)) &&
+           (ip_hdr(skb)->version == 4) &&
+           (ip_hdr(skb)->ihl == 5) &&
+           ((ip_hdr(skb)->frag_off == 0) ||
+            (ip_hdr(skb)->frag_off == htons(1 << 14))) &&
+           ((ip_hdr(skb)->protocol == IPPROTO_TCP) ||
+            (ip_hdr(skb)->protocol == IPPROTO_UDP))) {
                /* Use hardware checksum calc */
                pko_command.s.ipoffp1 = sizeof(struct ethhdr) + 1;
        }
@@ -563,7 +549,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
        /* Get a work queue entry */
        cvmx_wqe_t *work = cvmx_fpa_alloc(CVMX_FPA_WQE_POOL);
 
-       if (unlikely(work == NULL)) {
+       if (unlikely(!work)) {
                printk_ratelimited("%s: Failed to allocate a work queue entry\n",
                                   dev->name);
                priv->stats.tx_dropped++;
@@ -576,7 +562,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
        if (unlikely(packet_buffer == NULL)) {
                printk_ratelimited("%s: Failed to allocate a packet buffer\n",
                                   dev->name);
-               cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, DONT_WRITEBACK(1));
+               cvmx_fpa_free(work, CVMX_FPA_WQE_POOL, 1);
                priv->stats.tx_dropped++;
                dev_kfree_skb_any(skb);
                return 0;
@@ -590,7 +576,7 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
         * calculation may add a little extra, but that doesn't
         * hurt.
         */
-       copy_location = packet_buffer + sizeof(uint64_t);
+       copy_location = packet_buffer + sizeof(u64);
        copy_location += ((CVMX_HELPER_FIRST_MBUFF_SKIP + 7) & 0xfff8) + 6;
 
        /*
@@ -605,13 +591,14 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
         * Fill in some of the work queue fields. We may need to add
         * more if the software at the other end needs them.
         */
-       work->hw_chksum = skb->csum;
-       work->len = skb->len;
-       work->ipprt = priv->port;
-       work->qos = priv->port & 0x7;
-       work->grp = pow_send_group;
-       work->tag_type = CVMX_HELPER_INPUT_TAG_TYPE;
-       work->tag = pow_send_group;     /* FIXME */
+       if (!OCTEON_IS_MODEL(OCTEON_CN68XX))
+               work->word0.pip.cn38xx.hw_chksum = skb->csum;
+       work->word1.len = skb->len;
+       cvmx_wqe_set_port(work, priv->port);
+       cvmx_wqe_set_qos(work, priv->port & 0x7);
+       cvmx_wqe_set_grp(work, pow_send_group);
+       work->word1.tag_type = CVMX_HELPER_INPUT_TAG_TYPE;
+       work->word1.tag = pow_send_group;       /* FIXME */
        /* Default to zero. Sets of zero later are commented out */
        work->word2.u64 = 0;
        work->word2.s.bufs = 1;
@@ -691,8 +678,8 @@ int cvm_oct_xmit_pow(struct sk_buff *skb, struct net_device *dev)
        }
 
        /* Submit the packet to the POW */
-       cvmx_pow_work_submit(work, work->tag, work->tag_type, work->qos,
-                            work->grp);
+       cvmx_pow_work_submit(work, work->word1.tag, work->word1.tag_type,
+                            cvmx_wqe_get_qos(work), cvmx_wqe_get_grp(work));
        priv->stats.tx_packets++;
        priv->stats.tx_bytes += skb->len;
        dev_consume_skb_any(skb);