drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_action.c

Source file repositories/reference/linux-study-clean/drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_action.c

File Facts

System
Linux kernel
Corpus path
drivers/net/ethernet/mellanox/mlx5/core/steering/sws/dr_action.c
Extension
.c
Size
70334 bytes
Lines
2246
Domain
Driver Families
Bucket
drivers/net
Inferred role
Driver Families: implementation source
Status
source implementation candidate

Why This File Exists

Repeatable hardware-adapter layer. Deep compatibility for every driver is out of scope; this atlas records patterns, probe lifecycles, bus glue, IRQ/DMA usage, and links back to core abstractions.

Dependency Surface

Detected Declarations

Annotated Snippet

if (dest_action->dest_tbl->is_fw_tbl) {
			*final_icm_addr = dest_action->dest_tbl->fw_tbl.rx_icm_addr;
		} else {
			mlx5dr_dbg(dmn,
				   "Destination FT should be terminating when modify TTL is used\n");
			return -EINVAL;
		}
		break;

	case DR_ACTION_TYP_VPORT:
		/* If destination is vport we will get the FW flow table
		 * that recalculates the CS and forwards to the vport.
		 */
		ret = mlx5dr_domain_get_recalc_cs_ft_addr(dest_action->vport->dmn,
							  dest_action->vport->caps->num,
							  final_icm_addr);
		if (ret) {
			mlx5dr_err(dmn, "Failed to get FW cs recalc flow table\n");
			return ret;
		}
		break;

	default:
		break;
	}

	return 0;
}

static void dr_action_modify_ttl_adjust(struct mlx5dr_domain *dmn,
					struct mlx5dr_ste_actions_attr *attr,
					bool rx_rule,
					bool *recalc_cs_required)
{
	*recalc_cs_required = false;

	/* if device supports csum recalculation - no adjustment needed */
	if (mlx5dr_ste_supp_ttl_cs_recalc(&dmn->info.caps))
		return;

	/* no adjustment needed on TX rules */
	if (!rx_rule)
		return;

	if (!MLX5_CAP_ESW_FLOWTABLE(dmn->mdev, fdb_ipv4_ttl_modify)) {
		/* Ignore the modify TTL action.
		 * It is always kept as last HW action.
		 */
		attr->modify_actions--;
		return;
	}

	if (dmn->type == MLX5DR_DOMAIN_TYPE_FDB)
		/* Due to a HW bug on some devices, modifying TTL on RX flows
		 * will cause an incorrect checksum calculation. In such cases
		 * we will use a FW table to recalculate the checksum.
		 */
		*recalc_cs_required = true;
}

static void dr_action_print_sequence(struct mlx5dr_domain *dmn,
				     struct mlx5dr_action *actions[],
				     int last_idx)
{
	int i;

	for (i = 0; i <= last_idx; i++)
		mlx5dr_err(dmn, "< %s (%d) > ",
			   dr_action_id_to_str(actions[i]->action_type),
			   actions[i]->action_type);
}

static int dr_action_get_dest_fw_tbl_addr(struct mlx5dr_matcher *matcher,
					  struct mlx5dr_action_dest_tbl *dest_tbl,
					  bool is_rx_rule,
					  u64 *final_icm_addr)
{
	struct mlx5dr_cmd_query_flow_table_details output;
	struct mlx5dr_domain *dmn = matcher->tbl->dmn;
	int ret;

	if (!dest_tbl->fw_tbl.rx_icm_addr) {
		ret = mlx5dr_cmd_query_flow_table(dmn->mdev,
						  dest_tbl->fw_tbl.type,
						  dest_tbl->fw_tbl.id,
						  &output);
		if (ret) {
			mlx5dr_err(dmn,
				   "Failed mlx5_cmd_query_flow_table ret: %d\n",
				   ret);

Annotation

Implementation Notes