diff options
| author | Hariprasad Shenai <hariprasad@chelsio.com> | 2015-04-14 16:32:33 -0400 |
|---|---|---|
| committer | David S. Miller <davem@davemloft.net> | 2015-04-14 15:08:52 -0400 |
| commit | 0aac3f56d4a63f049268fec78ead525a9227fead (patch) | |
| tree | 066f3870bc081d7029914e754d5e13cb7afb5773 /drivers/net/ethernet/chelsio | |
| parent | d52ce9203746254e010dc7f0f3c260d5a5f4b640 (diff) | |
cxgb4: Add comment for calculate tx flits and sge length code
Add comment for tx filt and sge length calucaltion code, also remove
a hardcoded value
Signed-off-by: Hariprasad Shenai <hariprasad@chelsio.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
Diffstat (limited to 'drivers/net/ethernet/chelsio')
| -rw-r--r-- | drivers/net/ethernet/chelsio/cxgb4/sge.c | 36 |
1 files changed, 35 insertions, 1 deletions
diff --git a/drivers/net/ethernet/chelsio/cxgb4/sge.c b/drivers/net/ethernet/chelsio/cxgb4/sge.c index 6af4bab6059c..1a31e40f0c2d 100644 --- a/drivers/net/ethernet/chelsio/cxgb4/sge.c +++ b/drivers/net/ethernet/chelsio/cxgb4/sge.c | |||
| @@ -730,6 +730,22 @@ static void *alloc_ring(struct device *dev, size_t nelem, size_t elem_size, | |||
| 730 | */ | 730 | */ |
| 731 | static inline unsigned int sgl_len(unsigned int n) | 731 | static inline unsigned int sgl_len(unsigned int n) |
| 732 | { | 732 | { |
| 733 | /* A Direct Scatter Gather List uses 32-bit lengths and 64-bit PCI DMA | ||
| 734 | * addresses. The DSGL Work Request starts off with a 32-bit DSGL | ||
| 735 | * ULPTX header, then Length0, then Address0, then, for 1 <= i <= N, | ||
| 736 | * repeated sequences of { Length[i], Length[i+1], Address[i], | ||
| 737 | * Address[i+1] } (this ensures that all addresses are on 64-bit | ||
| 738 | * boundaries). If N is even, then Length[N+1] should be set to 0 and | ||
| 739 | * Address[N+1] is omitted. | ||
| 740 | * | ||
| 741 | * The following calculation incorporates all of the above. It's | ||
| 742 | * somewhat hard to follow but, briefly: the "+2" accounts for the | ||
| 743 | * first two flits which include the DSGL header, Length0 and | ||
| 744 | * Address0; the "(3*(n-1))/2" covers the main body of list entries (3 | ||
| 745 | * flits for every pair of the remaining N) +1 if (n-1) is odd; and | ||
| 746 | * finally the "+((n-1)&1)" adds the one remaining flit needed if | ||
| 747 | * (n-1) is odd ... | ||
| 748 | */ | ||
| 733 | n--; | 749 | n--; |
| 734 | return (3 * n) / 2 + (n & 1) + 2; | 750 | return (3 * n) / 2 + (n & 1) + 2; |
| 735 | } | 751 | } |
| @@ -777,12 +793,30 @@ static inline unsigned int calc_tx_flits(const struct sk_buff *skb) | |||
| 777 | unsigned int flits; | 793 | unsigned int flits; |
| 778 | int hdrlen = is_eth_imm(skb); | 794 | int hdrlen = is_eth_imm(skb); |
| 779 | 795 | ||
| 796 | /* If the skb is small enough, we can pump it out as a work request | ||
| 797 | * with only immediate data. In that case we just have to have the | ||
| 798 | * TX Packet header plus the skb data in the Work Request. | ||
| 799 | */ | ||
| 800 | |||
| 780 | if (hdrlen) | 801 | if (hdrlen) |
| 781 | return DIV_ROUND_UP(skb->len + hdrlen, sizeof(__be64)); | 802 | return DIV_ROUND_UP(skb->len + hdrlen, sizeof(__be64)); |
| 782 | 803 | ||
| 804 | /* Otherwise, we're going to have to construct a Scatter gather list | ||
| 805 | * of the skb body and fragments. We also include the flits necessary | ||
| 806 | * for the TX Packet Work Request and CPL. We always have a firmware | ||
| 807 | * Write Header (incorporated as part of the cpl_tx_pkt_lso and | ||
| 808 | * cpl_tx_pkt structures), followed by either a TX Packet Write CPL | ||
| 809 | * message or, if we're doing a Large Send Offload, an LSO CPL message | ||
| 810 | * with an embedded TX Packet Write CPL message. | ||
| 811 | */ | ||
| 783 | flits = sgl_len(skb_shinfo(skb)->nr_frags + 1) + 4; | 812 | flits = sgl_len(skb_shinfo(skb)->nr_frags + 1) + 4; |
| 784 | if (skb_shinfo(skb)->gso_size) | 813 | if (skb_shinfo(skb)->gso_size) |
| 785 | flits += 2; | 814 | flits += (sizeof(struct fw_eth_tx_pkt_wr) + |
| 815 | sizeof(struct cpl_tx_pkt_lso_core) + | ||
| 816 | sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64); | ||
| 817 | else | ||
| 818 | flits += (sizeof(struct fw_eth_tx_pkt_wr) + | ||
| 819 | sizeof(struct cpl_tx_pkt_core)) / sizeof(__be64); | ||
| 786 | return flits; | 820 | return flits; |
| 787 | } | 821 | } |
| 788 | 822 | ||
