switchdev+ flower

Posted dream397

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了switchdev+ flower相关的知识,希望对你有一定的参考价值。

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的主要内容,如果未能解决你的问题,请参考以下文章

switchdev

switchdev

Linux Kernel TCP/IP Stack — L2 Layer — switchdev L2 Offload

Tensorflow2 图像分类-Flowers数据及分类代码详解

花店橱窗布置问题(FLOWER)

Tensorflow2 图像分类-Flowers数据深度学习模型保存读取参数查看和图像预测