aboutsummaryrefslogtreecommitdiffstats
path: root/drivers/net/vmxnet3/vmxnet3_drv.c
diff options
context:
space:
mode:
Diffstat (limited to 'drivers/net/vmxnet3/vmxnet3_drv.c')
-rw-r--r--drivers/net/vmxnet3/vmxnet3_drv.c63
1 files changed, 26 insertions, 37 deletions
diff --git a/drivers/net/vmxnet3/vmxnet3_drv.c b/drivers/net/vmxnet3/vmxnet3_drv.c
index 756c0f5565a5..3f04ba0a5454 100644
--- a/drivers/net/vmxnet3/vmxnet3_drv.c
+++ b/drivers/net/vmxnet3/vmxnet3_drv.c
@@ -537,11 +537,8 @@ vmxnet3_tq_create(struct vmxnet3_tx_queue *tq,
tq->buf_info = kcalloc(tq->tx_ring.size, sizeof(tq->buf_info[0]),
GFP_KERNEL);
- if (!tq->buf_info) {
- printk(KERN_ERR "%s: failed to allocate tx bufinfo\n",
- adapter->netdev->name);
+ if (!tq->buf_info)
goto err;
- }
return 0;
@@ -636,7 +633,7 @@ vmxnet3_rq_alloc_rx_buf(struct vmxnet3_rx_queue *rq, u32 ring_idx,
dev_dbg(&adapter->netdev->dev,
"alloc_rx_buf: %d allocated, next2fill %u, next2comp "
- "%u, uncommited %u\n", num_allocated, ring->next2fill,
+ "%u, uncommitted %u\n", num_allocated, ring->next2fill,
ring->next2comp, rq->uncommitted[ring_idx]);
/* so that the device can distinguish a full ring and an empty ring */
@@ -816,22 +813,19 @@ vmxnet3_parse_and_copy_hdr(struct sk_buff *skb, struct vmxnet3_tx_queue *tq,
if (ctx->mss) { /* TSO */
ctx->eth_ip_hdr_size = skb_transport_offset(skb);
- ctx->l4_hdr_size = ((struct tcphdr *)
- skb_transport_header(skb))->doff * 4;
+ ctx->l4_hdr_size = tcp_hdrlen(skb);
ctx->copy_size = ctx->eth_ip_hdr_size + ctx->l4_hdr_size;
} else {
if (skb->ip_summed == CHECKSUM_PARTIAL) {
ctx->eth_ip_hdr_size = skb_checksum_start_offset(skb);
if (ctx->ipv4) {
- struct iphdr *iph = (struct iphdr *)
- skb_network_header(skb);
+ const struct iphdr *iph = ip_hdr(skb);
+
if (iph->protocol == IPPROTO_TCP)
- ctx->l4_hdr_size = ((struct tcphdr *)
- skb_transport_header(skb))->doff * 4;
+ ctx->l4_hdr_size = tcp_hdrlen(skb);
else if (iph->protocol == IPPROTO_UDP)
- ctx->l4_hdr_size =
- sizeof(struct udphdr);
+ ctx->l4_hdr_size = sizeof(struct udphdr);
else
ctx->l4_hdr_size = 0;
} else {
@@ -876,14 +870,17 @@ static void
vmxnet3_prepare_tso(struct sk_buff *skb,
struct vmxnet3_tx_ctx *ctx)
{
- struct tcphdr *tcph = (struct tcphdr *)skb_transport_header(skb);
+ struct tcphdr *tcph = tcp_hdr(skb);
+
if (ctx->ipv4) {
- struct iphdr *iph = (struct iphdr *)skb_network_header(skb);
+ struct iphdr *iph = ip_hdr(skb);
+
iph->check = 0;
tcph->check = ~csum_tcpudp_magic(iph->saddr, iph->daddr, 0,
IPPROTO_TCP, 0);
} else {
- struct ipv6hdr *iph = (struct ipv6hdr *)skb_network_header(skb);
+ struct ipv6hdr *iph = ipv6_hdr(skb);
+
tcph->check = ~csum_ipv6_magic(&iph->saddr, &iph->daddr, 0,
IPPROTO_TCP, 0);
}
@@ -1514,11 +1511,9 @@ vmxnet3_rq_create(struct vmxnet3_rx_queue *rq, struct vmxnet3_adapter *adapter)
sz = sizeof(struct vmxnet3_rx_buf_info) * (rq->rx_ring[0].size +
rq->rx_ring[1].size);
bi = kzalloc(sz, GFP_KERNEL);
- if (!bi) {
- printk(KERN_ERR "%s: failed to allocate rx bufinfo\n",
- adapter->netdev->name);
+ if (!bi)
goto err;
- }
+
rq->buf_info[0] = bi;
rq->buf_info[1] = bi + rq->rx_ring[0].size;
@@ -2704,8 +2699,8 @@ vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter,
adapter->intr.num_intrs = vectors;
return 0;
} else if (err < 0) {
- printk(KERN_ERR "Failed to enable MSI-X for %s, error"
- " %d\n", adapter->netdev->name, err);
+ netdev_err(adapter->netdev,
+ "Failed to enable MSI-X, error: %d\n", err);
vectors = 0;
} else if (err < vector_threshold) {
break;
@@ -2713,15 +2708,15 @@ vmxnet3_acquire_msix_vectors(struct vmxnet3_adapter *adapter,
/* If fails to enable required number of MSI-x vectors
* try enabling minimum number of vectors required.
*/
+ netdev_err(adapter->netdev,
+ "Failed to enable %d MSI-X, trying %d instead\n",
+ vectors, vector_threshold);
vectors = vector_threshold;
- printk(KERN_ERR "Failed to enable %d MSI-X for %s, try"
- " %d instead\n", vectors, adapter->netdev->name,
- vector_threshold);
}
}
- printk(KERN_INFO "Number of MSI-X interrupts which can be allocatedi"
- " are lower than min threshold required.\n");
+ netdev_info(adapter->netdev,
+ "Number of MSI-X interrupts which can be allocated are lower than min threshold required.\n");
return err;
}
@@ -2787,8 +2782,9 @@ vmxnet3_alloc_intr_resources(struct vmxnet3_adapter *adapter)
return;
/* If we cannot allocate MSIx vectors use only one rx queue */
- printk(KERN_INFO "Failed to enable MSI-X for %s, error %d."
- "#rx queues : 1, try MSI\n", adapter->netdev->name, err);
+ netdev_info(adapter->netdev,
+ "Failed to enable MSI-X, error %d . Limiting #rx queues to 1, try MSI.\n",
+ err);
adapter->intr.type = VMXNET3_IT_MSI;
}
@@ -2918,11 +2914,8 @@ vmxnet3_probe_device(struct pci_dev *pdev,
printk(KERN_INFO "# of Tx queues : %d, # of Rx queues : %d\n",
num_tx_queues, num_rx_queues);
- if (!netdev) {
- printk(KERN_ERR "Failed to alloc ethernet device for adapter "
- "%s\n", pci_name(pdev));
+ if (!netdev)
return -ENOMEM;
- }
pci_set_drvdata(pdev, netdev);
adapter = netdev_priv(netdev);
@@ -2959,8 +2952,6 @@ vmxnet3_probe_device(struct pci_dev *pdev,
adapter->pm_conf = kmalloc(sizeof(struct Vmxnet3_PMConf), GFP_KERNEL);
if (adapter->pm_conf == NULL) {
- printk(KERN_ERR "Failed to allocate memory for %s\n",
- pci_name(pdev));
err = -ENOMEM;
goto err_alloc_pm;
}
@@ -2969,8 +2960,6 @@ vmxnet3_probe_device(struct pci_dev *pdev,
adapter->rss_conf = kmalloc(sizeof(struct UPT1_RSSConf), GFP_KERNEL);
if (adapter->rss_conf == NULL) {
- printk(KERN_ERR "Failed to allocate memory for %s\n",
- pci_name(pdev));
err = -ENOMEM;
goto err_alloc_rss;
}