MCPcopy Create free account
hub / github.com/F-Stack/f-stack / ngbe_fc_hpbthresh_set

Function ngbe_fc_hpbthresh_set

dpdk/drivers/net/ngbe/ngbe_ethdev.c:2426–2461  ·  view source on GitHub ↗

* ngbe_fc_hpbthresh_set - calculate high water mark for flow control * * @dv_id: device interface delay * @pb: packet buffer to calculate */

Source from the content-addressed store, hash-verified

2424 * @pb: packet buffer to calculate
2425 */
2426static s32
2427ngbe_fc_hpbthresh_set(struct rte_eth_dev *dev)
2428{
2429 struct ngbe_hw *hw = ngbe_dev_hw(dev);
2430 struct rte_pci_device *pci_dev = RTE_ETH_DEV_TO_PCI(dev);
2431 u32 max_frame_size, tc, dv_id, rx_pb;
2432 s32 kb, marker;
2433
2434 /* Calculate max LAN frame size */
2435 max_frame_size = rd32m(hw, NGBE_FRMSZ, NGBE_FRMSZ_MAX_MASK);
2436 tc = max_frame_size + NGBE_ETH_FRAMING;
2437
2438 /* Calculate delay value for device */
2439 dv_id = NGBE_DV(tc, tc);
2440
2441 /* Loopback switch introduces additional latency */
2442 if (pci_dev->max_vfs)
2443 dv_id += NGBE_B2BT(tc);
2444
2445 /* Delay value is calculated in bit times convert to KB */
2446 kb = NGBE_BT2KB(dv_id);
2447 rx_pb = rd32(hw, NGBE_PBRXSIZE) >> 10;
2448
2449 marker = rx_pb - kb;
2450
2451 /* It is possible that the packet buffer is not large enough
2452 * to provide required headroom. In this case throw an error
2453 * to user and do the best we can.
2454 */
2455 if (marker < 0) {
2456 PMD_DRV_LOG(WARNING, "Packet Buffer can not provide enough headroom to support flow control.");
2457 marker = tc + 1;
2458 }
2459
2460 return marker;
2461}
2462
2463/*
2464 * ngbe_fc_lpbthresh_set - calculate low water mark for flow control

Callers 1

ngbe_pbthresh_setFunction · 0.85

Calls 3

ngbe_dev_hwFunction · 0.85
rd32mFunction · 0.50
rd32Function · 0.50

Tested by

no test coverage detected