can: mcp251xfd: add RX IRQ coalescing ethtool support
This patch adds support ethtool based configuration for the RX IRQ coalescing added in the previous patch. Link: https://lore.kernel.org/20220313083640.501791-10-mkl@pengutronix.de Signed-off-by: Marc Kleine-Budde <mkl@pengutronix.de>
This commit is contained in:
parent
60a848c50d
commit
846990e0ed
@ -46,14 +46,69 @@ mcp251xfd_ring_set_ringparam(struct net_device *ndev,
|
||||
return -EBUSY;
|
||||
|
||||
priv->rx_obj_num = layout.cur_rx;
|
||||
priv->rx_obj_num_coalesce_irq = layout.rx_coalesce;
|
||||
priv->tx->obj_num = layout.cur_tx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcp251xfd_ring_get_coalesce(struct net_device *ndev,
|
||||
struct ethtool_coalesce *ec,
|
||||
struct kernel_ethtool_coalesce *kec,
|
||||
struct netlink_ext_ack *ext_ack)
|
||||
{
|
||||
struct mcp251xfd_priv *priv = netdev_priv(ndev);
|
||||
u32 rx_max_frames;
|
||||
|
||||
/* The ethtool doc says:
|
||||
* To disable coalescing, set usecs = 0 and max_frames = 1.
|
||||
*/
|
||||
if (priv->rx_obj_num_coalesce_irq == 0)
|
||||
rx_max_frames = 1;
|
||||
else
|
||||
rx_max_frames = priv->rx_obj_num_coalesce_irq;
|
||||
|
||||
ec->rx_max_coalesced_frames_irq = rx_max_frames;
|
||||
ec->rx_coalesce_usecs_irq = priv->rx_coalesce_usecs_irq;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static int mcp251xfd_ring_set_coalesce(struct net_device *ndev,
|
||||
struct ethtool_coalesce *ec,
|
||||
struct kernel_ethtool_coalesce *kec,
|
||||
struct netlink_ext_ack *ext_ack)
|
||||
{
|
||||
struct mcp251xfd_priv *priv = netdev_priv(ndev);
|
||||
const bool fd_mode = mcp251xfd_is_fd_mode(priv);
|
||||
const struct ethtool_ringparam ring = {
|
||||
.rx_pending = priv->rx_obj_num,
|
||||
.tx_pending = priv->tx->obj_num,
|
||||
};
|
||||
struct can_ram_layout layout;
|
||||
|
||||
can_ram_get_layout(&layout, &mcp251xfd_ram_config, &ring, ec, fd_mode);
|
||||
|
||||
if ((layout.rx_coalesce != priv->rx_obj_num_coalesce_irq ||
|
||||
ec->rx_coalesce_usecs_irq != priv->rx_coalesce_usecs_irq) &&
|
||||
netif_running(ndev))
|
||||
return -EBUSY;
|
||||
|
||||
priv->rx_obj_num = layout.cur_rx;
|
||||
priv->rx_obj_num_coalesce_irq = layout.rx_coalesce;
|
||||
priv->rx_coalesce_usecs_irq = ec->rx_coalesce_usecs_irq;
|
||||
priv->tx->obj_num = layout.cur_tx;
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
static const struct ethtool_ops mcp251xfd_ethtool_ops = {
|
||||
.supported_coalesce_params = ETHTOOL_COALESCE_RX_USECS_IRQ |
|
||||
ETHTOOL_COALESCE_RX_MAX_FRAMES_IRQ,
|
||||
.get_ringparam = mcp251xfd_ring_get_ringparam,
|
||||
.set_ringparam = mcp251xfd_ring_set_ringparam,
|
||||
.get_coalesce = mcp251xfd_ring_get_coalesce,
|
||||
.set_coalesce = mcp251xfd_ring_set_coalesce,
|
||||
};
|
||||
|
||||
void mcp251xfd_ethtool_init(struct mcp251xfd_priv *priv)
|
||||
|
@ -374,6 +374,7 @@ const struct can_ram_config mcp251xfd_ram_config = {
|
||||
.def[CAN_RAM_MODE_CANFD] = CAN_RAM_NUM_MAX,
|
||||
.fifo_num = MCP251XFD_FIFO_RX_NUM,
|
||||
.fifo_depth_min = MCP251XFD_RX_FIFO_DEPTH_MIN,
|
||||
.fifo_depth_coalesce_min = MCP251XFD_RX_FIFO_DEPTH_COALESCE_MIN,
|
||||
},
|
||||
.tx = {
|
||||
.size[CAN_RAM_MODE_CAN] = sizeof(struct mcp251xfd_hw_tef_obj) +
|
||||
|
@ -406,6 +406,7 @@ static_assert(MCP251XFD_TIMESTAMP_WORK_DELAY_SEC <
|
||||
#define MCP251XFD_RX_OBJ_NUM_MIN 16U
|
||||
#define MCP251XFD_RX_OBJ_NUM_MAX (MCP251XFD_FIFO_RX_NUM * MCP251XFD_FIFO_DEPTH)
|
||||
#define MCP251XFD_RX_FIFO_DEPTH_MIN 4U
|
||||
#define MCP251XFD_RX_FIFO_DEPTH_COALESCE_MIN 8U
|
||||
|
||||
#define MCP251XFD_TX_OBJ_NUM_MIN 2U
|
||||
#define MCP251XFD_TX_OBJ_NUM_MAX 8U
|
||||
|
Loading…
x
Reference in New Issue
Block a user