码迷,mamicode.com
首页 > 其他好文 > 详细

switchdev(三)+ flower

时间:2020-05-07 13:33:24      阅读:77      评论:0      收藏:0      [点我收藏+]

标签:ethtool   lin   str   chain   close   option   oid   void   class   

static int bnxt_setup_flower(struct net_device *dev,
                 struct tc_cls_flower_offload *cls_flower)
{
    struct tc_mqprio_qopt *mqprio = type_data;
    struct bnxt *bp = netdev_priv(dev);

    if (type != TC_SETUP_MQPRIO)
    if (BNXT_VF(bp))
        return -EOPNOTSUPP;

    mqprio->hw = TC_MQPRIO_HW_OFFLOAD_TCS;
    return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, cls_flower);
}
int bnxt_tc_setup_flower(struct bnxt *bp, u16 src_fid,
             struct flow_cls_offload *cls_flower)
{
    switch (cls_flower->command) {
    case FLOW_CLS_REPLACE:
        return bnxt_tc_add_flow(bp, src_fid, cls_flower);
    case FLOW_CLS_DESTROY:
        return bnxt_tc_del_flow(bp, cls_flower);
    case FLOW_CLS_STATS:
        return bnxt_tc_get_flow_stats(bp, cls_flower);
    default:
        return -EOPNOTSUPP;
    }
}
config BNXT_FLOWER_OFFLOAD
	bool "TC Flower offload support for NetXtreme-C/E"
	depends on BNXT
	default y
	---help---
	  This configuration parameter enables TC Flower packet classifier
	  offload for eswitch.  This option enables SR-IOV switchdev eswitch
	  offload.


static int bnxt_setup_tc_block_cb(enum tc_setup_type type, void *type_data,
                  void *cb_priv)
{
    struct bnxt *bp = cb_priv;

    if (!bnxt_tc_flower_enabled(bp) ||
        !tc_cls_can_offload_and_chain0(bp->dev, type_data))
        return -EOPNOTSUPP;

    switch (type) {
    case TC_SETUP_CLSFLOWER:
        return bnxt_tc_setup_flower(bp, bp->pf.fw_fid, type_data);
    default:
        return -EOPNOTSUPP;
    }
}

 

static int mlx5e_rep_ndo_setup_tc(struct net_device *dev, u32 handle,
                  __be16 proto, struct tc_to_netdev *tc)
{
    struct mlx5e_priv *priv = netdev_priv(dev);

    if (TC_H_MAJ(handle) != TC_H_MAJ(TC_H_INGRESS))
        return -EOPNOTSUPP;

    switch (tc->type) {
    case TC_SETUP_CLSFLOWER:
        switch (tc->cls_flower->command) {
        case TC_CLSFLOWER_REPLACE:
            return mlx5e_configure_flower(priv, proto, tc->cls_flower);
        case TC_CLSFLOWER_DESTROY:
            return mlx5e_delete_flower(priv, tc->cls_flower);
        case TC_CLSFLOWER_STATS:
            return mlx5e_stats_flower(priv, tc->cls_flower);
        }
    default:
        return -EOPNOTSUPP;
    }
}
static const struct net_device_ops mlx5e_netdev_ops_rep = {
    .ndo_open                = mlx5e_open,
    .ndo_stop                = mlx5e_close,
    .ndo_start_xmit          = mlx5e_xmit,
    .ndo_get_phys_port_name  = mlx5e_rep_get_phys_port_name,
    .ndo_setup_tc            = mlx5e_rep_ndo_setup_tc,
    .ndo_get_stats64         = mlx5e_get_stats,
};
static void mlx5e_build_rep_netdev(struct net_device *netdev)
{
    netdev->netdev_ops = &mlx5e_netdev_ops_rep;

    netdev->watchdog_timeo    = 15 * HZ;

    netdev->ethtool_ops      = &mlx5e_rep_ethtool_ops;

#ifdef CONFIG_NET_SWITCHDEV
    netdev->switchdev_ops = &mlx5e_rep_switchdev_ops;
#endif

    netdev->features     |= NETIF_F_VLAN_CHALLENGED | NETIF_F_HW_TC;
    netdev->hw_features      |= NETIF_F_HW_TC;

    eth_hw_addr_random(netdev);
}

 

switchdev(三)+ flower

标签:ethtool   lin   str   chain   close   option   oid   void   class   

原文地址:https://www.cnblogs.com/dream397/p/12842097.html

(0)
(0)
   
举报
评论 一句话评论(0
登录后才能评论!
© 2014 mamicode.com 版权所有  联系我们:gaon5@hotmail.com
迷上了代码!