ravb: Factorise ravb_set_features

RZ/G2L supports HW checksum on RX and TX whereas R-Car supports on RX.
Factorise ravb_set_features to support this feature.

Signed-off-by: Biju Das <biju.das.jz@bp.renesas.com>
Reviewed-by: Lad Prabhakar <prabhakar.mahadev-lad.rj@bp.renesas.com>
Signed-off-by: David S. Miller <davem@davemloft.net>
This commit is contained in:
Biju Das 2021-08-25 08:01:51 +01:00 committed by David S. Miller
parent cb21104f2c
commit 80f35a0df0
2 changed files with 14 additions and 2 deletions

View File

@ -985,6 +985,7 @@ struct ravb_hw_info {
void *(*alloc_rx_desc)(struct net_device *ndev, int q);
bool (*receive)(struct net_device *ndev, int *quota, int q);
void (*set_rate)(struct net_device *ndev);
int (*set_rx_csum_feature)(struct net_device *ndev, netdev_features_t features);
const char (*gstrings_stats)[ETH_GSTRING_LEN];
size_t gstrings_size;
netdev_features_t net_hw_features;

View File

@ -1901,7 +1901,7 @@ static void ravb_set_rx_csum(struct net_device *ndev, bool enable)
spin_unlock_irqrestore(&priv->lock, flags);
}
static int ravb_set_features(struct net_device *ndev,
static int ravb_set_features_rx_csum(struct net_device *ndev,
netdev_features_t features)
{
netdev_features_t changed = ndev->features ^ features;
@ -1914,6 +1914,15 @@ static int ravb_set_features(struct net_device *ndev,
return 0;
}
static int ravb_set_features(struct net_device *ndev,
netdev_features_t features)
{
struct ravb_private *priv = netdev_priv(ndev);
const struct ravb_hw_info *info = priv->info;
return info->set_rx_csum_feature(ndev, features);
}
static const struct net_device_ops ravb_netdev_ops = {
.ndo_open = ravb_open,
.ndo_stop = ravb_close,
@ -1980,6 +1989,7 @@ static const struct ravb_hw_info ravb_gen3_hw_info = {
.alloc_rx_desc = ravb_alloc_rx_desc,
.receive = ravb_rcar_rx,
.set_rate = ravb_set_rate,
.set_rx_csum_feature = ravb_set_features_rx_csum,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,
@ -1998,6 +2008,7 @@ static const struct ravb_hw_info ravb_gen2_hw_info = {
.alloc_rx_desc = ravb_alloc_rx_desc,
.receive = ravb_rcar_rx,
.set_rate = ravb_set_rate,
.set_rx_csum_feature = ravb_set_features_rx_csum,
.gstrings_stats = ravb_gstrings_stats,
.gstrings_size = sizeof(ravb_gstrings_stats),
.net_hw_features = NETIF_F_RXCSUM,