src/dpdk/drivers/net/mvpp2/mrvl_flow.c
static int
mrvl_parse_ip4_addr(const struct rte_flow_item_ipv4 *spec,
		    const struct rte_flow_item_ipv4 *mask,
		    int parse_dst, struct rte_flow *flow)
{
	struct pp2_cls_rule_key_field *key_field;
	struct in_addr k;
	uint32_t m;

	memset(&k, 0, sizeof(k));
	if (parse_dst) {
		k.s_addr = spec->hdr.dst_addr;
		m = rte_be_to_cpu_32(mask->hdr.dst_addr);

		flow->table_key.proto_field[flow->rule.num_fields].field.ipv4 =
			MV_NET_IP4_F_DA;
	} else {
		k.s_addr = spec->hdr.src_addr;
		m = rte_be_to_cpu_32(mask->hdr.src_addr);

		flow->table_key.proto_field[flow->rule.num_fields].field.ipv4 =
			MV_NET_IP4_F_SA;
	}

	key_field = &flow->rule.fields[flow->rule.num_fields];
	mrvl_alloc_key_mask(key_field);
	key_field->size = 4;

	inet_ntop(AF_INET, &k, (char *)key_field->key, MRVL_CLS_STR_SIZE_MAX);
	snprintf((char *)key_field->mask, MRVL_CLS_STR_SIZE_MAX, "0x%x", m);

	flow->table_key.proto_field[flow->rule.num_fields].proto =
		MV_NET_PROTO_IP4;
	flow->table_key.key_size += key_field->size;

	flow->rule.num_fields += 1;

	return 0;
}
/**
 * Parse either source or destination ip addresses of the ipv4 flow item.
 *
 * This will create classifier rule that matches either destination
 * or source ip field.
 *
 * @param spec Pointer to the specific flow item.
 * @param mask Pointer to the specific flow item's mask.
 * @param parse_dst Parse either destination or source ip address.
 * @param flow Pointer to the flow.
 * @return 0 in case of success, negative error value otherwise.
 */
Parse either source or destination ip addresses of the ipv4 flow item.
This will create classifier rule that matches either destination
or source ip field.

@param spec Pointer to the specific flow item.
@param mask Pointer to the specific flow item's mask.
@param parse_dst Parse either destination or source ip address.
@param flow Pointer to the flow.
@return 0 in case of success, negative error value otherwise.
Parse either source or destination ip addresses of the ipv4 flow item . This will create classifier rule that matches either destination or source ip field . @param spec Pointer to the specific flow item . @param mask Pointer to the specific flow item ' s mask . @param parse_dst Parse either destination or source ip address . @param flow Pointer to the flow . @return 0 in case of success negative error value otherwise .
static int
mrvl_parse_ip4_addr(const struct rte_flow_item_ipv4 *spec,
		    const struct rte_flow_item_ipv4 *mask,
		    int parse_dst, struct rte_flow *flow)
{
	struct pp2_cls_rule_key_field *key_field;
	struct in_addr k;
	uint32_t m;
	memset(&k, 0, sizeof(k));
	if (parse_dst) {
		k.s_addr = spec->hdr.dst_addr;
		m = rte_be_to_cpu_32(mask->hdr.dst_addr);
		flow->table_key.proto_field[flow->rule.num_fields].field.ipv4 =
			MV_NET_IP4_F_DA;
	} else {
		k.s_addr = spec->hdr.src_addr;
		m = rte_be_to_cpu_32(mask->hdr.src_addr);
		flow->table_key.proto_field[flow->rule.num_fields].field.ipv4 =
			MV_NET_IP4_F_SA;
	}
	key_field = &flow->rule.fields[flow->rule.num_fields];
	mrvl_alloc_key_mask(key_field);
	key_field->size = 4;
	inet_ntop(AF_INET, &k, (char *)key_field->key, MRVL_CLS_STR_SIZE_MAX);
	snprintf((char *)key_field->mask, MRVL_CLS_STR_SIZE_MAX, "0x%x", m);
	flow->table_key.proto_field[flow->rule.num_fields].proto =
		MV_NET_PROTO_IP4;
	flow->table_key.key_size += key_field->size;
	flow->rule.num_fields += 1;
	return 0;
}
static int mrvl_parse_ip4_addr ( const struct rte_flow_item_ipv4 * spec , const struct rte_flow_item_ipv4 * mask , int parse_dst , struct rte_flow * flow ) { struct pp2_cls_rule_key_field * key_field ; struct in_addr k ; uint32_t m ; memset ( & k , 0 , sizeof ( k ) ) ; if ( parse_dst ) { k . s_addr = spec -> hdr . dst_addr ; m = rte_be_to_cpu_32 ( mask -> hdr . dst_addr ) ; flow -> table_key . proto_field [ flow -> rule . num_fields ] . field . ipv4 = MV_NET_IP4_F_DA ; } else { k . s_addr = spec -> hdr . src_addr ; m = rte_be_to_cpu_32 ( mask -> hdr . src_addr ) ; flow -> table_key . proto_field [ flow -> rule . num_fields ] . field . ipv4 = MV_NET_IP4_F_SA ; } key_field = & flow -> rule . fields [ flow -> rule . num_fields ] ; mrvl_alloc_key_mask ( key_field ) ; key_field -> size = 4 ; inet_ntop ( AF_INET , & k , ( char * ) key_field -> key , MRVL_CLS_STR_SIZE_MAX ) ; snprintf ( ( char * ) key_field -> mask , MRVL_CLS_STR_SIZE_MAX , " " , m ) ; flow -> table_key . proto_field [ flow -> rule . num_fields ] . proto = MV_NET_PROTO_IP4 ; flow -> table_key . key_size += key_field -> size ; flow -> rule . num_fields += 1 ; return 0 ; }
Parse either source or destination ip addresses of the ipv4 flow item.
Parse either source or destination ip addresses of the ipv4 flow item .