Donate to e Foundation | Murena handsets with /e/OS | Own a part of Murena! Learn more

Commit 71feeef6 authored by David S. Miller's avatar David S. Miller
Browse files

Merge branch 'net-sched-summer-cleanup-part-2-ndo_setup_tc'



Jiri Pirko says:

====================
net: sched: summer cleanup part 2, ndo_setup_tc

This patchset focuses on ndo_setup_tc and its args.
Currently there are couple of things that do not make much sense.
The type is passed in struct tc_to_netdev, but as it is always
required, should be arg of the ndo. Other things are passed as args
but they are only relevant for cls offloads and not mqprio. Therefore,
they should be pushed to struct. As the tc_to_netdev struct in the end
is just a container of single pointer, we get rid of it and pass the
struct according to type. So in the end, we have:
ndo_setup_tc(dev, type, type_data_struct)

There are couple of cosmetics done on the way to make things smooth.
Also, reported error is consolidated to eopnotsupp in case the
asked offload is not supported.

v1->v2:
- added forgotten hns3pf bits
====================

Acked-by: default avatarJamal Hadi Salim <jhs@mojatatu.com>
Signed-off-by: default avatarDavid S. Miller <davem@davemloft.net>
parents 1afec92b de4784ca
Loading
Loading
Loading
Loading
+7 −7
Original line number Diff line number Diff line
@@ -1918,18 +1918,18 @@ static void xgbe_poll_controller(struct net_device *netdev)
}
#endif /* End CONFIG_NET_POLL_CONTROLLER */

static int xgbe_setup_tc(struct net_device *netdev, u32 handle, u32 chain_index,
			 __be16 proto,
			 struct tc_to_netdev *tc_to_netdev)
static int xgbe_setup_tc(struct net_device *netdev, enum tc_setup_type type,
			 void *type_data)
{
	struct xgbe_prv_data *pdata = netdev_priv(netdev);
	struct tc_mqprio_qopt *mqprio = type_data;
	u8 tc;

	if (tc_to_netdev->type != TC_SETUP_MQPRIO)
		return -EINVAL;
	if (type != TC_SETUP_MQPRIO)
		return -EOPNOTSUPP;

	tc_to_netdev->mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
	tc = tc_to_netdev->mqprio->num_tc;
	mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
	tc = mqprio->num_tc;

	if (tc > pdata->hw_feat.tc_cnt)
		return -EINVAL;
+8 −6
Original line number Diff line number Diff line
@@ -4284,15 +4284,17 @@ int bnx2x_setup_tc(struct net_device *dev, u8 num_tc)
	return 0;
}

int __bnx2x_setup_tc(struct net_device *dev, u32 handle, u32 chain_index,
		     __be16 proto, struct tc_to_netdev *tc)
int __bnx2x_setup_tc(struct net_device *dev, enum tc_setup_type type,
		     void *type_data)
{
	if (tc->type != TC_SETUP_MQPRIO)
		return -EINVAL;
	struct tc_mqprio_qopt *mqprio = type_data;

	if (type != TC_SETUP_MQPRIO)
		return -EOPNOTSUPP;

	tc->mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
	mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;

	return bnx2x_setup_tc(dev, tc->mqprio->num_tc);
	return bnx2x_setup_tc(dev, mqprio->num_tc);
}

/* called with rtnl_lock */
+2 −2
Original line number Diff line number Diff line
@@ -486,8 +486,8 @@ netdev_tx_t bnx2x_start_xmit(struct sk_buff *skb, struct net_device *dev);

/* setup_tc callback */
int bnx2x_setup_tc(struct net_device *dev, u8 num_tc);
int __bnx2x_setup_tc(struct net_device *dev, u32 handle, u32 chain_index,
		     __be16 proto, struct tc_to_netdev *tc);
int __bnx2x_setup_tc(struct net_device *dev, enum tc_setup_type type,
		     void *type_data);

int bnx2x_get_vf_config(struct net_device *dev, int vf,
			struct ifla_vf_info *ivi);
+8 −6
Original line number Diff line number Diff line
@@ -7237,15 +7237,17 @@ int bnxt_setup_mq_tc(struct net_device *dev, u8 tc)
	return 0;
}

static int bnxt_setup_tc(struct net_device *dev, u32 handle, u32 chain_index,
			 __be16 proto, struct tc_to_netdev *ntc)
static int bnxt_setup_tc(struct net_device *dev, enum tc_setup_type type,
			 void *type_data)
{
	if (ntc->type != TC_SETUP_MQPRIO)
		return -EINVAL;
	struct tc_mqprio_qopt *mqprio = type_data;

	if (type != TC_SETUP_MQPRIO)
		return -EOPNOTSUPP;

	ntc->mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
	mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;

	return bnxt_setup_mq_tc(dev, ntc->mqprio->num_tc);
	return bnxt_setup_mq_tc(dev, mqprio->num_tc);
}

#ifdef CONFIG_RFS_ACCEL
+25 −18
Original line number Diff line number Diff line
@@ -2889,14 +2889,29 @@ static int cxgb_set_tx_maxrate(struct net_device *dev, int index, u32 rate)
	return err;
}

static int cxgb_setup_tc(struct net_device *dev, u32 handle, u32 chain_index,
			 __be16 proto, struct tc_to_netdev *tc)
static int cxgb_setup_tc_cls_u32(struct net_device *dev,
				 struct tc_cls_u32_offload *cls_u32)
{
	struct port_info *pi = netdev2pinfo(dev);
	struct adapter *adap = netdev2adap(dev);
	if (TC_H_MAJ(cls_u32->common.handle) != TC_H_MAJ(TC_H_INGRESS) ||
	    cls_u32->common.chain_index)
		return -EOPNOTSUPP;

	if (chain_index)
	switch (cls_u32->command) {
	case TC_CLSU32_NEW_KNODE:
	case TC_CLSU32_REPLACE_KNODE:
		return cxgb4_config_knode(dev, cls_u32);
	case TC_CLSU32_DELETE_KNODE:
		return cxgb4_delete_knode(dev, cls_u32);
	default:
		return -EOPNOTSUPP;
	}
}

static int cxgb_setup_tc(struct net_device *dev, enum tc_setup_type type,
			 void *type_data)
{
	struct port_info *pi = netdev2pinfo(dev);
	struct adapter *adap = netdev2adap(dev);

	if (!(adap->flags & FULL_INIT_DONE)) {
		dev_err(adap->pdev_dev,
@@ -2905,22 +2920,14 @@ static int cxgb_setup_tc(struct net_device *dev, u32 handle, u32 chain_index,
		return -EINVAL;
	}

	if (TC_H_MAJ(handle) == TC_H_MAJ(TC_H_INGRESS) &&
	    tc->type == TC_SETUP_CLSU32) {
		switch (tc->cls_u32->command) {
		case TC_CLSU32_NEW_KNODE:
		case TC_CLSU32_REPLACE_KNODE:
			return cxgb4_config_knode(dev, proto, tc->cls_u32);
		case TC_CLSU32_DELETE_KNODE:
			return cxgb4_delete_knode(dev, proto, tc->cls_u32);
	switch (type) {
	case TC_SETUP_CLSU32:
		return cxgb_setup_tc_cls_u32(dev, type_data);
	default:
		return -EOPNOTSUPP;
	}
}

	return -EOPNOTSUPP;
}

static netdev_features_t cxgb_fix_features(struct net_device *dev,
					   netdev_features_t features)
{
Loading