diff options
author | Eric Dumazet <edumazet@google.com> | 2014-10-05 05:35:09 -0400 |
---|---|---|
committer | David S. Miller <davem@davemloft.net> | 2014-10-06 01:04:15 -0400 |
commit | 7dfa4b414d4eec8da56e44fb2b4aea3e549b092f (patch) | |
tree | b8c45159b7ce66d1efefed6bb59d8ba257f2d547 | |
parent | f2600cf02b5b59aaee082c3485b7f01fc7f7b70c (diff) |
net/mlx4_en: Code cleanups in tx path
- Remove unused variable ring->poll_cnt
- No need to set some fields if using blueflame
- Add missing const's
- Use unlikely
- Remove unneeded new line
- Make some comments more precise
- struct mlx4_bf @offset field reduced to unsigned int to save space
Signed-off-by: Eric Dumazet <edumazet@google.com>
Signed-off-by: Amir Vadai <amirv@mellanox.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/en_tx.c | 49 | ||||
-rw-r--r-- | drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | 1 | ||||
-rw-r--r-- | include/linux/mlx4/device.h | 2 |
3 files changed, 27 insertions, 25 deletions
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_tx.c b/drivers/net/ethernet/mellanox/mlx4/en_tx.c index 0c501253fdab..eaf23eb7266a 100644 --- a/drivers/net/ethernet/mellanox/mlx4/en_tx.c +++ b/drivers/net/ethernet/mellanox/mlx4/en_tx.c | |||
@@ -191,7 +191,6 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, | |||
191 | ring->prod = 0; | 191 | ring->prod = 0; |
192 | ring->cons = 0xffffffff; | 192 | ring->cons = 0xffffffff; |
193 | ring->last_nr_txbb = 1; | 193 | ring->last_nr_txbb = 1; |
194 | ring->poll_cnt = 0; | ||
195 | memset(ring->tx_info, 0, ring->size * sizeof(struct mlx4_en_tx_info)); | 194 | memset(ring->tx_info, 0, ring->size * sizeof(struct mlx4_en_tx_info)); |
196 | memset(ring->buf, 0, ring->buf_size); | 195 | memset(ring->buf, 0, ring->buf_size); |
197 | 196 | ||
@@ -512,7 +511,8 @@ static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv, | |||
512 | return ring->buf + index * TXBB_SIZE; | 511 | return ring->buf + index * TXBB_SIZE; |
513 | } | 512 | } |
514 | 513 | ||
515 | static int is_inline(int inline_thold, struct sk_buff *skb, void **pfrag) | 514 | static bool is_inline(int inline_thold, const struct sk_buff *skb, |
515 | void **pfrag) | ||
516 | { | 516 | { |
517 | void *ptr; | 517 | void *ptr; |
518 | 518 | ||
@@ -535,7 +535,7 @@ static int is_inline(int inline_thold, struct sk_buff *skb, void **pfrag) | |||
535 | return 0; | 535 | return 0; |
536 | } | 536 | } |
537 | 537 | ||
538 | static int inline_size(struct sk_buff *skb) | 538 | static int inline_size(const struct sk_buff *skb) |
539 | { | 539 | { |
540 | if (skb->len + CTRL_SIZE + sizeof(struct mlx4_wqe_inline_seg) | 540 | if (skb->len + CTRL_SIZE + sizeof(struct mlx4_wqe_inline_seg) |
541 | <= MLX4_INLINE_ALIGN) | 541 | <= MLX4_INLINE_ALIGN) |
@@ -546,7 +546,8 @@ static int inline_size(struct sk_buff *skb) | |||
546 | sizeof(struct mlx4_wqe_inline_seg), 16); | 546 | sizeof(struct mlx4_wqe_inline_seg), 16); |
547 | } | 547 | } |
548 | 548 | ||
549 | static int get_real_size(struct sk_buff *skb, struct net_device *dev, | 549 | static int get_real_size(const struct sk_buff *skb, |
550 | struct net_device *dev, | ||
550 | int *lso_header_size) | 551 | int *lso_header_size) |
551 | { | 552 | { |
552 | struct mlx4_en_priv *priv = netdev_priv(dev); | 553 | struct mlx4_en_priv *priv = netdev_priv(dev); |
@@ -581,8 +582,10 @@ static int get_real_size(struct sk_buff *skb, struct net_device *dev, | |||
581 | return real_size; | 582 | return real_size; |
582 | } | 583 | } |
583 | 584 | ||
584 | static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *skb, | 585 | static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, |
585 | int real_size, u16 *vlan_tag, int tx_ind, void *fragptr) | 586 | const struct sk_buff *skb, |
587 | int real_size, u16 *vlan_tag, | ||
588 | int tx_ind, void *fragptr) | ||
586 | { | 589 | { |
587 | struct mlx4_wqe_inline_seg *inl = &tx_desc->inl; | 590 | struct mlx4_wqe_inline_seg *inl = &tx_desc->inl; |
588 | int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl; | 591 | int spc = MLX4_INLINE_ALIGN - CTRL_SIZE - sizeof *inl; |
@@ -642,7 +645,8 @@ u16 mlx4_en_select_queue(struct net_device *dev, struct sk_buff *skb, | |||
642 | return fallback(dev, skb) % rings_p_up + up * rings_p_up; | 645 | return fallback(dev, skb) % rings_p_up + up * rings_p_up; |
643 | } | 646 | } |
644 | 647 | ||
645 | static void mlx4_bf_copy(void __iomem *dst, unsigned long *src, unsigned bytecnt) | 648 | static void mlx4_bf_copy(void __iomem *dst, const void *src, |
649 | unsigned int bytecnt) | ||
646 | { | 650 | { |
647 | __iowrite64_copy(dst, src, bytecnt / 8); | 651 | __iowrite64_copy(dst, src, bytecnt / 8); |
648 | } | 652 | } |
@@ -736,11 +740,10 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
736 | tx_info->skb = skb; | 740 | tx_info->skb = skb; |
737 | tx_info->nr_txbb = nr_txbb; | 741 | tx_info->nr_txbb = nr_txbb; |
738 | 742 | ||
743 | data = &tx_desc->data; | ||
739 | if (lso_header_size) | 744 | if (lso_header_size) |
740 | data = ((void *)&tx_desc->lso + ALIGN(lso_header_size + 4, | 745 | data = ((void *)&tx_desc->lso + ALIGN(lso_header_size + 4, |
741 | DS_SIZE)); | 746 | DS_SIZE)); |
742 | else | ||
743 | data = &tx_desc->data; | ||
744 | 747 | ||
745 | /* valid only for none inline segments */ | 748 | /* valid only for none inline segments */ |
746 | tx_info->data_offset = (void *)data - (void *)tx_desc; | 749 | tx_info->data_offset = (void *)data - (void *)tx_desc; |
@@ -753,9 +756,9 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
753 | if (is_inline(ring->inline_thold, skb, &fragptr)) { | 756 | if (is_inline(ring->inline_thold, skb, &fragptr)) { |
754 | tx_info->inl = 1; | 757 | tx_info->inl = 1; |
755 | } else { | 758 | } else { |
756 | /* Map fragments */ | 759 | /* Map fragments if any */ |
757 | for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) { | 760 | for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) { |
758 | struct skb_frag_struct *frag; | 761 | const struct skb_frag_struct *frag; |
759 | dma_addr_t dma; | 762 | dma_addr_t dma; |
760 | 763 | ||
761 | frag = &skb_shinfo(skb)->frags[i]; | 764 | frag = &skb_shinfo(skb)->frags[i]; |
@@ -772,7 +775,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
772 | --data; | 775 | --data; |
773 | } | 776 | } |
774 | 777 | ||
775 | /* Map linear part */ | 778 | /* Map linear part if needed */ |
776 | if (tx_info->linear) { | 779 | if (tx_info->linear) { |
777 | u32 byte_count = skb_headlen(skb) - lso_header_size; | 780 | u32 byte_count = skb_headlen(skb) - lso_header_size; |
778 | dma_addr_t dma; | 781 | dma_addr_t dma; |
@@ -795,18 +798,14 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
795 | * For timestamping add flag to skb_shinfo and | 798 | * For timestamping add flag to skb_shinfo and |
796 | * set flag for further reference | 799 | * set flag for further reference |
797 | */ | 800 | */ |
798 | if (ring->hwtstamp_tx_type == HWTSTAMP_TX_ON && | 801 | if (unlikely(ring->hwtstamp_tx_type == HWTSTAMP_TX_ON && |
799 | skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) { | 802 | shinfo->tx_flags & SKBTX_HW_TSTAMP)) { |
800 | skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS; | 803 | shinfo->tx_flags |= SKBTX_IN_PROGRESS; |
801 | tx_info->ts_requested = 1; | 804 | tx_info->ts_requested = 1; |
802 | } | 805 | } |
803 | 806 | ||
804 | /* Prepare ctrl segement apart opcode+ownership, which depends on | 807 | /* Prepare ctrl segement apart opcode+ownership, which depends on |
805 | * whether LSO is used */ | 808 | * whether LSO is used */ |
806 | tx_desc->ctrl.vlan_tag = cpu_to_be16(vlan_tag); | ||
807 | tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_VLAN * | ||
808 | !!vlan_tx_tag_present(skb); | ||
809 | tx_desc->ctrl.fence_size = (real_size / 16) & 0x3f; | ||
810 | tx_desc->ctrl.srcrb_flags = priv->ctrl_flags; | 809 | tx_desc->ctrl.srcrb_flags = priv->ctrl_flags; |
811 | if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { | 810 | if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) { |
812 | tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | | 811 | tx_desc->ctrl.srcrb_flags |= cpu_to_be32(MLX4_WQE_CTRL_IP_CSUM | |
@@ -852,7 +851,6 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
852 | cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0); | 851 | cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0); |
853 | tx_info->nr_bytes = max_t(unsigned int, skb->len, ETH_ZLEN); | 852 | tx_info->nr_bytes = max_t(unsigned int, skb->len, ETH_ZLEN); |
854 | ring->packets++; | 853 | ring->packets++; |
855 | |||
856 | } | 854 | } |
857 | ring->bytes += tx_info->nr_bytes; | 855 | ring->bytes += tx_info->nr_bytes; |
858 | netdev_tx_sent_queue(ring->tx_queue, tx_info->nr_bytes); | 856 | netdev_tx_sent_queue(ring->tx_queue, tx_info->nr_bytes); |
@@ -874,7 +872,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
874 | ring->prod += nr_txbb; | 872 | ring->prod += nr_txbb; |
875 | 873 | ||
876 | /* If we used a bounce buffer then copy descriptor back into place */ | 874 | /* If we used a bounce buffer then copy descriptor back into place */ |
877 | if (bounce) | 875 | if (unlikely(bounce)) |
878 | tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size); | 876 | tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size); |
879 | 877 | ||
880 | skb_tx_timestamp(skb); | 878 | skb_tx_timestamp(skb); |
@@ -894,13 +892,18 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) | |||
894 | 892 | ||
895 | wmb(); | 893 | wmb(); |
896 | 894 | ||
897 | mlx4_bf_copy(ring->bf.reg + ring->bf.offset, (unsigned long *) &tx_desc->ctrl, | 895 | mlx4_bf_copy(ring->bf.reg + ring->bf.offset, &tx_desc->ctrl, |
898 | desc_size); | 896 | desc_size); |
899 | 897 | ||
900 | wmb(); | 898 | wmb(); |
901 | 899 | ||
902 | ring->bf.offset ^= ring->bf.buf_size; | 900 | ring->bf.offset ^= ring->bf.buf_size; |
903 | } else { | 901 | } else { |
902 | tx_desc->ctrl.vlan_tag = cpu_to_be16(vlan_tag); | ||
903 | tx_desc->ctrl.ins_vlan = MLX4_WQE_CTRL_INS_VLAN * | ||
904 | !!vlan_tx_tag_present(skb); | ||
905 | tx_desc->ctrl.fence_size = real_size; | ||
906 | |||
904 | /* Ensure new descriptor hits memory | 907 | /* Ensure new descriptor hits memory |
905 | * before setting ownership of this descriptor to HW | 908 | * before setting ownership of this descriptor to HW |
906 | */ | 909 | */ |
diff --git a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h index 84c9d5dbfa4f..e54b653de3d4 100644 --- a/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +++ b/drivers/net/ethernet/mellanox/mlx4/mlx4_en.h | |||
@@ -263,7 +263,6 @@ struct mlx4_en_tx_ring { | |||
263 | u32 buf_size; | 263 | u32 buf_size; |
264 | u32 doorbell_qpn; | 264 | u32 doorbell_qpn; |
265 | void *buf; | 265 | void *buf; |
266 | u16 poll_cnt; | ||
267 | struct mlx4_en_tx_info *tx_info; | 266 | struct mlx4_en_tx_info *tx_info; |
268 | u8 *bounce_buf; | 267 | u8 *bounce_buf; |
269 | u8 queue_index; | 268 | u8 queue_index; |
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h index b2f8ab9a57c4..37e4404d0227 100644 --- a/include/linux/mlx4/device.h +++ b/include/linux/mlx4/device.h | |||
@@ -583,7 +583,7 @@ struct mlx4_uar { | |||
583 | }; | 583 | }; |
584 | 584 | ||
585 | struct mlx4_bf { | 585 | struct mlx4_bf { |
586 | unsigned long offset; | 586 | unsigned int offset; |
587 | int buf_size; | 587 | int buf_size; |
588 | struct mlx4_uar *uar; | 588 | struct mlx4_uar *uar; |
589 | void __iomem *reg; | 589 | void __iomem *reg; |