* sgl_len - calculates the size of an SGL of the given capacity * @n: the number of SGL entries * * Calculates the number of flits needed for a scatter/gather list that * can hold the given number of entries. */
| 428 | * can hold the given number of entries. |
| 429 | */ |
| 430 | static inline unsigned int sgl_len(unsigned int n) |
| 431 | { |
| 432 | /* |
| 433 | * A Direct Scatter Gather List uses 32-bit lengths and 64-bit PCI DMA |
| 434 | * addresses. The DSGL Work Request starts off with a 32-bit DSGL |
| 435 | * ULPTX header, then Length0, then Address0, then, for 1 <= i <= N, |
| 436 | * repeated sequences of { Length[i], Length[i+1], Address[i], |
| 437 | * Address[i+1] } (this ensures that all addresses are on 64-bit |
| 438 | * boundaries). If N is even, then Length[N+1] should be set to 0 and |
| 439 | * Address[N+1] is omitted. |
| 440 | * |
| 441 | * The following calculation incorporates all of the above. It's |
| 442 | * somewhat hard to follow but, briefly: the "+2" accounts for the |
| 443 | * first two flits which include the DSGL header, Length0 and |
| 444 | * Address0; the "(3*(n-1))/2" covers the main body of list entries (3 |
| 445 | * flits for every pair of the remaining N) +1 if (n-1) is odd; and |
| 446 | * finally the "+((n-1)&1)" adds the one remaining flit needed if |
| 447 | * (n-1) is odd ... |
| 448 | */ |
| 449 | n--; |
| 450 | return (3 * n) / 2 + (n & 1) + 2; |
| 451 | } |
| 452 | |
| 453 | /** |
| 454 | * flits_to_desc - returns the num of Tx descriptors for the given flits |
no outgoing calls
no test coverage detected