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
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, · 314 unmodified lines
512 return ring->buf + index * TXBB_SIZE;511 return ring->buf + index * TXBB_SIZE;
513}512}
514 513
515static int is_inline(int inline_thold, struct sk_buff *skb, void **pfrag)514static 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) · 16 unmodified lines
535 return 0;535 return 0;
536}536}
537 537
538static int inline_size(struct sk_buff *skb)538static 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) · 4 unmodified lines
546 sizeof(struct mlx4_wqe_inline_seg), 16);546 sizeof(struct mlx4_wqe_inline_seg), 16);
547}547}
548 548
549static int get_real_size(struct sk_buff *skb, struct net_device *dev,549static 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, · 28 unmodified lines
581 return real_size;582 return real_size;
582}583}
583 584
584static void build_inline_wqe(struct mlx4_en_tx_desc *tx_desc, struct sk_buff *skb,585static 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, · 53 unmodified lines
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
645static void mlx4_bf_copy(void __iomem *dst, unsigned long *src, unsigned bytecnt)648static 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) · 87 unmodified lines
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) · 6 unmodified lines
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) · 10 unmodified lines
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) · 16 unmodified lines
795 * For timestamping add flag to skb_shinfo and798 * For timestamping add flag to skb_shinfo and
796 * set flag for further reference799 * 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 on807 /* 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) · 39 unmodified lines
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) · 15 unmodified lines
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) · 13 unmodified lines
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 memory907 /* Ensure new descriptor hits memory
905 * before setting ownership of this descriptor to HW908 * before setting ownership of this descriptor to HW
906 */909 */
drivers/net/ethernet/mellanox/mlx4/mlx4_en.h+0−1
@@ -263,7 +263,6 @@ struct mlx4_en_tx_ring { · 262 unmodified lines
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;
include/linux/mlx4/device.h+1−1
@@ -583,7 +583,7 @@ struct mlx4_uar { · 582 unmodified lines
583};583};
584 584
585struct mlx4_bf {585struct 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;

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