enic: Add support for rx_copybreak
v4 cover enic: Add support for rx_copybreak
The following series implements rx_copybreak.
dma_map_single()/dma_unmap_single() is more expensive than alloc_skb & memcpy for smaller packets. By doing this we can reuse the dma buff which is already mapped. This is very useful when iommu is on. The default skb copybreak value is 256.
When iommu is on, we can go much higher than 256. All the drivers that supports rx_copybreak provides module parameter to change this value. Since module parameter is the least preferred way for changing driver values, this series adds ethtool support for setting rx_copybreak.
v4:
Validate tunable length in ethtool_get_tunable, not in driver implemented function.
Loose tunable_ops array for each tunable type. Define one function and let the driver use switch case for each type.
Use double underscore for data type in UAPI headers. Use const qualifier where possible.
v3:
Add tunable namespace to ethtool. Use new ethtool cmd ETHTOOL_S/GTUNABLE to set/get rx_copybreak from userspace.
v2:
Add new ethtool_cmd for DMA buffer parameters, instead of adding new members to existing ethtool_ringparam.
Govindarajulu Varadarajan (3):
enic: implement rx_copybreak
ethtool: Add generic options for tunables
enic: Add tunable_ops support for rx_copybreak
drivers/net/ethernet/cisco/enic/enic.h | 1 + drivers/net/ethernet/cisco/enic/enic_ethtool.c | 39 +++++++++++++ drivers/net/ethernet/cisco/enic/enic_main.c | 50 +++++++++++++++- include/linux/ethtool.h | 4 ++ include/uapi/linux/ethtool.h | 28 +++++++++ net/core/ethtool.c | 81 ++++++++++++++++++++++++++ 6 files changed, 200 insertions(+), 3 deletions(-)
Signature · 1 line
2.1.0
PATCH v4 1/3 enic: implement rx_copybreak
Calling dma_map_single()/dma_unmap_single() is quite expensive compared to copying a small packet. So let's copy short frames and keep the buffers mapped.
--- drivers/net/ethernet/cisco/enic/enic.h | 1 + drivers/net/ethernet/cisco/enic/enic_main.c | 50 +++++++++++++++++++++++++++-- 2 files changed, 48 insertions(+), 3 deletions(-)
drivers/net/ethernet/cisco/enic/enic.h +1 -0
@@ -186,6 +186,7 @@ struct enic {____cacheline_aligned struct vnic_cq cq[ENIC_CQ_MAX ];unsigned int cq_count;struct enic_rfs_flw_tbl rfs_h; +u32 rx_copybreak; };static inline struct device *enic_get_dev (struct enic *enic)
drivers/net/ethernet/cisco/enic/enic_main.c +47 -3
93 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v4 2/3 ethtool: Add generic options for tunables
In reply to Govindarajulu VaradarajanThis patch adds new ethtool cmd, ETHTOOL_GTUNABLE & ETHTOOL_STUNABLE for getting tunable values from driver.
Add get_tunable and set_tunable to ethtool_ops. Driver implements these functions for getting/setting tunable value.
--- include/linux/ethtool.h | 4 +++ include/uapi/linux/ethtool.h | 28 +++++++++++++++ net/core/ethtool.c | 81 ++++++++++++++++++++++++++++++++++++++++++++ 3 files changed, 113 insertions(+)
include/linux/ethtool.h +4 -0
@@ -257,6 +257,10 @@ struct ethtool_ops { struct ethtool_eeprom *, u8 *);int (*get_eee)(struct net_device *,struct ethtool_eee *);int (*set_eee)(struct net_device *,struct ethtool_eee *); +int (*get_tunable)(struct net_device *, +const struct ethtool_tunable *,void *); +int (*set_tunable)(struct net_device *, +const struct ethtool_tunable *,const void *); };
include/uapi/linux/ethtool.h +28 -0
@@ -209,6 +209,32 @@ struct ethtool_value {__u32 data; }; +enum tunable_id { +ETHTOOL_ID_UNSPEC , +ETHTOOL_RX_COPYBREAK , +}; + +enum tunable_type_id { +ETHTOOL_TUNABLE_UNSPEC , +ETHTOOL_TUNABLE_U8 , +ETHTOOL_TUNABLE_U16 , +ETHTOOL_TUNABLE_U32 , +ETHTOOL_TUNABLE_U64 , +ETHTOOL_TUNABLE_STRING , +ETHTOOL_TUNABLE_S8 , +ETHTOOL_TUNABLE_S16 , +ETHTOOL_TUNABLE_S32 , +ETHTOOL_TUNABLE_S64 , +}; + +struct ethtool_tunable { +__u32 cmd; +__u32 id; +__u32 type_id; +__u32 len; +void *data[0 ]; +}; +/** * struct ethtool_regs - hardware register dump * @cmd: Command number = %ETHTOOL_GREGS
@@ -1152,6 +1178,8 @@ enum ethtool_sfeatures_retval_bits {#define ETHTOOL_GRSSH 0x00000046/* Get RX flow hash configuration */ #define ETHTOOL_SRSSH 0x00000047/* Set RX flow hash configuration */ +#define ETHTOOL_GTUNABLE 0x00000048/* Get tunable configuration */ +#define ETHTOOL_STUNABLE 0x00000049/* Set tunable configuration */ /* compatibility with older code */ #define SPARC_ETH_GSET ETHTOOL_GSET
net/core/ethtool.c +81 -0
99 lines not on this page · raw message
Signature · 1 line
2.1.0
PATCH v4 3/3 enic: Add tunable_ops support for rx_copybreak
In reply to Govindarajulu VaradarajanThis patch adds support for setting/getting rx_copybreak using generic ethtool tunable.
Defines enic_get_tunable() & enic_set_tunable() to get/set rx_copybreak. As of now, these two function supports only rx_copybreak.
--- drivers/net/ethernet/cisco/enic/enic_ethtool.c | 39 ++++++++++++++++++++++++++ 1 file changed, 39 insertions(+)
drivers/net/ethernet/cisco/enic/enic_ethtool.c +39 -0
@@ -379,6 +379,43 @@ static int enic_get_rxnfc(struct net_device *dev, struct ethtool_rxnfc *cmd,return ret; } +static int enic_get_tunable (struct net_device *dev, +const struct ethtool_tunable *tuna,void *data) +{ +struct enic *enic =netdev_priv (dev); +int ret =0 ; + +switch (tuna->id) { +case ETHTOOL_RX_COPYBREAK : + *(u32 *)data = enic->rx_copybreak; +break ; +default : + ret = -EINVAL ; +break ; + } + +return ret; +} + +static int enic_set_tunable (struct net_device *dev, +const struct ethtool_tunable *tuna, +const void *data) +{ +struct enic *enic =netdev_priv (dev); +int ret =0 ; + +switch (tuna->id) { +case ETHTOOL_RX_COPYBREAK : + enic->rx_copybreak = *(u32 *)data; +break ; +default : + ret = -EINVAL ; +break ; + } + +return ret; +} +static const struct ethtool_ops enic_ethtool_ops = { .get_settings = enic_get_settings, .get_drvinfo = enic_get_drvinfo,
@@ -391,6 +428,8 @@ static const struct ethtool_ops enic_ethtool_ops = { .get_coalesce = enic_get_coalesce, .set_coalesce = enic_set_coalesce, .get_rxnfc = enic_get_rxnfc, + .get_tunable = enic_get_tunable, + .set_tunable = enic_set_tunable, };void enic_set_ethtool_ops (struct net_device *netdev)
Signature · 1 line
2.1.0
David Miller
maintainerFrom: Govindarajulu Varadarajan <[email protected]>
Date: Wed, 3 Sep 2014 03:17:18 +0530
Quoted 1 line
The following series implements
rx_copybreak.
Series applied, thanks.