History

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

Eric Dumazet committed 12 years ago

Commit 7dfa4b41 parent f2600cf3 files · +27 −25Browse files

Unified · Split

3 files
  1. drivers/net/ethernet/mellanox/mlx4/en_tx.c +26 −23
  2. drivers/net/ethernet/mellanox/mlx4/mlx4_en.h +0 −1
  3. include/linux/mlx4/device.h +1 −1
drivers/net/ethernet/mellanox/mlx4/en_tx.c+26−23
@@ -191,7 +191,6 @@ int mlx4_en_activate_tx_ring(struct mlx4_en_priv *priv, · 190 unmodified lines
191191 ring->prod = 0;
192192 ring->cons = 0xffffffff;
193193 ring->last_nr_txbb = 1;
194− ring->poll_cnt = 0;
195194 memset(ring->tx_info, 0, ring->size * sizeof(struct mlx4_en_tx_info));
196195 memset(ring->buf, 0, ring->buf_size);
197196
@@ -512,7 +511,8 @@ static struct mlx4_en_tx_desc *mlx4_en_bounce_to_desc(struct mlx4_en_priv *priv, · 314 unmodified lines
512511 return ring->buf + index * TXBB_SIZE;
513512 }
514513
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)
516516 {
517517 void *ptr;
518518
@@ -535,7 +535,7 @@ static int is_inline(int inline_thold, struct sk_buff *skb, void **pfrag) · 16 unmodified lines
535535 return 0;
536536 }
537537
538−static int inline_size(struct sk_buff *skb)
538+static int inline_size(const struct sk_buff *skb)
539539 {
540540 if (skb->len + CTRL_SIZE + sizeof(struct mlx4_wqe_inline_seg)
541541 <= MLX4_INLINE_ALIGN)
@@ -546,7 +546,8 @@ static int inline_size(struct sk_buff *skb) · 4 unmodified lines
546546 sizeof(struct mlx4_wqe_inline_seg), 16);
547547 }
548548
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,
550551 int *lso_header_size)
551552 {
552553 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, · 28 unmodified lines
581582 return real_size;
582583 }
583584
584−static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *skb,
585− int real_size, u16 *vlan_tag, int tx_ind, void *fragptr)
585+static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc,
586+ const struct sk_buff *skb,
587+ int real_size, u16 *vlan_tag,
588+ int tx_ind, void *fragptr)
586589 {
587590 struct mlx4_wqe_inline_seg *inl = &tx_desc->inl;
588591 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, · 53 unmodified lines
642645 return fallback(dev, skb) % rings_p_up + up * rings_p_up;
643646 }
644647
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)
646650 {
647651 __iowrite64_copy(dst, src, bytecnt / 8);
648652 }
@@ -736,11 +740,10 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) · 87 unmodified lines
736740 tx_info->skb = skb;
737741 tx_info->nr_txbb = nr_txbb;
738742
743+ data = &tx_desc->data;
739744 if (lso_header_size)
740745 data = ((void *)&tx_desc->lso + ALIGN(lso_header_size + 4,
741746 DS_SIZE));
742− else
743− data = &tx_desc->data;
744747
745748 /* valid only for none inline segments */
746749 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) · 6 unmodified lines
753756 if (is_inline(ring->inline_thold, skb, &fragptr)) {
754757 tx_info->inl = 1;
755758 } else {
756− /* Map fragments */
759+ /* Map fragments if any */
757760 for (i = skb_shinfo(skb)->nr_frags - 1; i >= 0; i--) {
758− struct skb_frag_struct *frag;
761+ const struct skb_frag_struct *frag;
759762 dma_addr_t dma;
760763
761764 frag = &skb_shinfo(skb)->frags[i];
@@ -772,7 +775,7 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) · 10 unmodified lines
772775 --data;
773776 }
774777
775− /* Map linear part */
778+ /* Map linear part if needed */
776779 if (tx_info->linear) {
777780 u32 byte_count = skb_headlen(skb) - lso_header_size;
778781 dma_addr_t dma;
@@ -795,18 +798,14 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) · 16 unmodified lines
795798 * For timestamping add flag to skb_shinfo and
796799 * set flag for further reference
797800 */
798− if (ring->hwtstamp_tx_type == HWTSTAMP_TX_ON &&
799− skb_shinfo(skb)->tx_flags & SKBTX_HW_TSTAMP) {
800− skb_shinfo(skb)->tx_flags |= SKBTX_IN_PROGRESS;
801+ if (unlikely(ring->hwtstamp_tx_type == HWTSTAMP_TX_ON &&
802+ shinfo->tx_flags & SKBTX_HW_TSTAMP)) {
803+ shinfo->tx_flags |= SKBTX_IN_PROGRESS;
801804 tx_info->ts_requested = 1;
802805 }
803806
804807 /* Prepare ctrl segement apart opcode+ownership, which depends on
805808 * 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;
810809 tx_desc->ctrl.srcrb_flags = priv->ctrl_flags;
811810 if (likely(skb->ip_summed == CHECKSUM_PARTIAL)) {
812811 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) · 39 unmodified lines
852851 cpu_to_be32(MLX4_EN_BIT_DESC_OWN) : 0);
853852 tx_info->nr_bytes = max_t(unsigned int, skb->len, ETH_ZLEN);
854853 ring->packets++;
855−
856854 }
857855 ring->bytes += tx_info->nr_bytes;
858856 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) · 15 unmodified lines
874872 ring->prod += nr_txbb;
875873
876874 /* If we used a bounce buffer then copy descriptor back into place */
877− if (bounce)
875+ if (unlikely(bounce))
878876 tx_desc = mlx4_en_bounce_to_desc(priv, ring, index, desc_size);
879877
880878 skb_tx_timestamp(skb);
@@ -894,13 +892,18 @@ netdev_tx_t mlx4_en_xmit(struct sk_buff *skb, struct net_device *dev) · 13 unmodified lines
894892
895893 wmb();
896894
897− mlx4_bf_copy(ring->bf.reg + ring->bf.offset, (unsigned long *) &tx_desc->ctrl,
898− desc_size);
895+ mlx4_bf_copy(ring->bf.reg + ring->bf.offset, &tx_desc->ctrl,
896+ desc_size);
899897
900898 wmb();
901899
902900 ring->bf.offset ^= ring->bf.buf_size;
903901 } 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+
904907 /* Ensure new descriptor hits memory
905908 * before setting ownership of this descriptor to HW
906909 */
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h+0−1
@@ -263,7 +263,6 @@ struct mlx4_en_tx_ring { · 262 unmodified lines
263263 u32 buf_size;
264264 u32 doorbell_qpn;
265265 void *buf;
266− u16 poll_cnt;
267266 struct mlx4_en_tx_info *tx_info;
268267 u8 *bounce_buf;
269268 u8 queue_index;
include/linux/mlx4/device.h+1−1
@@ -583,7 +583,7 @@ struct mlx4_uar { · 582 unmodified lines
583583 };
584584
585585 struct mlx4_bf {
586− unsigned long offset;
586+ unsigned int offset;
587587 int buf_size;
588588 struct mlx4_uar *uar;
589589 void __iomem *reg;

Keyboard shortcuts

General

Show keyboard shortcuts
?
Focus the current search
/

Issues and pull requests

Open filters
f

Issues, pull requests and Inbox

Select next item
j↓
Select previous item
k↑
Open selected item
Enter
Dismiss filters or clear selection
Esc

Repository code

Go to file
t