@@ -19,6 +19,8 @@ RSS hash = Y
RSS key update = Y
RSS reta update = Y
Inner RSS = Y
+VLAN filter = Y
+VLAN offload = Y
L3 checksum offload = Y
L4 checksum offload = Y
Inner L3 checksum = Y
@@ -1601,3 +1601,37 @@ sssnic_flow_ctrl_get(struct sssnic_hw *hw, bool *autoneg, bool *rx_en,
return 0;
}
+
+int
+sssnic_vlan_filter_set(struct sssnic_hw *hw, uint16_t vid, bool add)
+{
+ int ret;
+ struct sssnic_vlan_filter_set_cmd cmd;
+ struct sssnic_msg msg;
+ uint32_t cmd_len;
+
+ memset(&cmd, 0, sizeof(cmd));
+ cmd.function = SSSNIC_FUNC_IDX(hw);
+ cmd.add = add ? 1 : 0;
+ cmd.vid = vid;
+ cmd_len = sizeof(cmd);
+
+ sssnic_msg_init(&msg, (uint8_t *)&cmd, cmd_len,
+ SSSNIC_SET_PORT_VLAN_FILTER_CMD, SSSNIC_MPU_FUNC_IDX,
+ SSSNIC_LAN_MODULE, SSSNIC_MSG_TYPE_REQ);
+
+ ret = sssnic_mbox_send(hw, &msg, (uint8_t *)&cmd, &cmd_len, 0);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed to send mbox message, ret=%d", ret);
+ return ret;
+ }
+
+ if (cmd_len == 0 || cmd.common.status != 0) {
+ PMD_DRV_LOG(ERR,
+ "Bad response to SSSNIC_SET_PORT_VLAN_FILTER_CMD, len=%u, status=%u",
+ cmd_len, cmd.common.status);
+ return -EIO;
+ }
+
+ return 0;
+}
@@ -469,5 +469,6 @@ int sssnic_flow_ctrl_set(struct sssnic_hw *hw, bool autoneg, bool rx_en,
bool tx_en);
int sssnic_flow_ctrl_get(struct sssnic_hw *hw, bool *autoneg, bool *rx_en,
bool *tx_en);
+int sssnic_vlan_filter_set(struct sssnic_hw *hw, uint16_t vid, bool add);
#endif /* _SSSNIC_API_H_ */
@@ -425,4 +425,13 @@ struct sssnic_flow_ctrl_cmd {
uint8_t resvd1[5];
};
+struct sssnic_vlan_filter_set_cmd {
+ struct sssnic_cmd_common common;
+ uint16_t function;
+ uint8_t add;
+ uint8_t resvd0;
+ uint16_t vid;
+ uint16_t resvd1;
+};
+
#endif /* _SSSNIC_CMD_H_ */
@@ -16,6 +16,7 @@
#include "sssnic_ethdev_rss.h"
static int sssnic_ethdev_init(struct rte_eth_dev *ethdev);
+static void sssnic_ethdev_vlan_filter_clean(struct rte_eth_dev *ethdev);
static int
sssnic_ethdev_infos_get(struct rte_eth_dev *ethdev,
@@ -340,6 +341,7 @@ sssnic_ethdev_release(struct rte_eth_dev *ethdev)
{
struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+ sssnic_ethdev_vlan_filter_clean(ethdev);
sssnic_ethdev_link_intr_disable(ethdev);
sssnic_ethdev_tx_queue_all_release(ethdev);
sssnic_ethdev_rx_queue_all_release(ethdev);
@@ -821,6 +823,89 @@ sssnic_ethdev_flow_ctrl_get(struct rte_eth_dev *ethdev,
return 0;
}
+static int
+sssnic_ethdev_vlan_offload_set(struct rte_eth_dev *ethdev, int mask)
+{
+ struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+ struct rte_eth_conf *dev_conf = ðdev->data->dev_conf;
+ uint8_t vlan_strip_en;
+ uint32_t vlan_filter_en;
+ int ret;
+
+ if (mask & RTE_ETH_VLAN_STRIP_MASK) {
+ if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_STRIP)
+ vlan_strip_en = 1;
+ else
+ vlan_strip_en = 0;
+
+ ret = sssnic_vlan_strip_enable_set(hw, vlan_strip_en);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed to %s vlan strip offload",
+ vlan_strip_en ? "enable" : "disable");
+ return ret;
+ }
+ }
+
+ if (mask & RTE_ETH_VLAN_FILTER_MASK) {
+ if (dev_conf->rxmode.offloads & RTE_ETH_RX_OFFLOAD_VLAN_FILTER)
+ vlan_filter_en = 1;
+ else
+ vlan_filter_en = 0;
+
+ ret = sssnic_vlan_filter_enable_set(hw, vlan_filter_en);
+ if (ret != 0) {
+ PMD_DRV_LOG(ERR, "Failed to %s vlan filter offload",
+ vlan_filter_en ? "enable" : "disable");
+ return ret;
+ }
+ }
+
+ return 0;
+}
+
+static int
+sssnic_ethdev_vlan_filter_get(struct rte_eth_dev *ethdev, uint16_t vlan_id)
+{
+ struct rte_vlan_filter_conf *vfc = ðdev->data->vlan_filter_conf;
+ int vidx = vlan_id / 64;
+ int vbit = vlan_id % 64;
+
+ return !!(vfc->ids[vidx] & RTE_BIT64(vbit));
+}
+
+static int
+sssnic_ethdev_vlan_filter_set(struct rte_eth_dev *ethdev, uint16_t vlan_id,
+ int on)
+{
+ struct sssnic_hw *hw = SSSNIC_ETHDEV_TO_HW(ethdev);
+ int ret;
+
+ if (sssnic_ethdev_vlan_filter_get(ethdev, vlan_id) == !!on)
+ return 0;
+
+ ret = sssnic_vlan_filter_set(hw, vlan_id, !!on);
+ if (ret) {
+ PMD_DRV_LOG(ERR,
+ "Failed to %s VLAN filter, vlan_id: %u, port: %u",
+ on ? "add" : "remove", vlan_id, ethdev->data->port_id);
+ return ret;
+ }
+
+ PMD_DRV_LOG(DEBUG, "%s VLAN %u filter to port %u",
+ on ? "Added" : "Removed", vlan_id, ethdev->data->port_id);
+
+ return 0;
+}
+
+static void
+sssnic_ethdev_vlan_filter_clean(struct rte_eth_dev *ethdev)
+{
+ uint16_t vlan_id;
+
+ for (vlan_id = 0; vlan_id <= RTE_ETHER_MAX_VLAN_ID; vlan_id++)
+ sssnic_ethdev_vlan_filter_set(ethdev, vlan_id, 0);
+}
+
static const struct eth_dev_ops sssnic_ethdev_ops = {
.dev_start = sssnic_ethdev_start,
.dev_stop = sssnic_ethdev_stop,
@@ -864,6 +949,8 @@ static const struct eth_dev_ops sssnic_ethdev_ops = {
.fw_version_get = sssnic_ethdev_fw_version_get,
.flow_ctrl_set = sssnic_ethdev_flow_ctrl_set,
.flow_ctrl_get = sssnic_ethdev_flow_ctrl_get,
+ .vlan_offload_set = sssnic_ethdev_vlan_offload_set,
+ .vlan_filter_set = sssnic_ethdev_vlan_filter_set,
};
static int