msm: ipa: add new IPA filtering bitmap

Add new IPA filtering bitmap to match inner IP type
and inner IPv4 address in L2TP use case.

Change-Id: I30afbfba6fb0150ab90826eb2543540699ab895b
Acked-by: Shihuan Liu <shihuanl@qti.qualcomm.com>
Signed-off-by: Skylar Chang <chiaweic@codeaurora.org>
This commit is contained in:
Shihuan Liu 2017-09-28 17:46:41 -07:00 committed by Gerrit - the friendly Code Review server
parent a5cabe9334
commit 05ec87e351
5 changed files with 148 additions and 0 deletions

View file

@ -580,6 +580,15 @@ static int ipa_attrib_dump(struct ipa_rule_attrib *attrib,
if (attrib->attrib_mask & IPA_FLT_MAC_ETHER_TYPE)
pr_err("ether_type:%x ", attrib->ether_type);
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IP_TYPE)
pr_err("l2tp inner ip type: %d ", attrib->type);
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IPV4_DST_ADDR) {
addr[0] = htonl(attrib->u.v4.dst_addr);
mask[0] = htonl(attrib->u.v4.dst_addr_mask);
pr_err("dst_addr:%pI4 dst_addr_mask:%pI4 ", addr, mask);
}
pr_err("\n");
return 0;
}

View file

@ -1475,6 +1475,37 @@ int ipa_generate_hw_rule(enum ipa_ip_type ip,
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IP_TYPE) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
IPAERR("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
/* 22 => offset of IP type after v6 header */
*buf = ipa_write_8(22, *buf);
*buf = ipa_write_32(0xF0000000, *buf);
if (attrib->type == 0x40)
*buf = ipa_write_32(0x40000000, *buf);
else
*buf = ipa_write_32(0x60000000, *buf);
*buf = ipa_pad_to_32(*buf);
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IPV4_DST_ADDR) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
IPAERR("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
/* 38 => offset of inner IPv4 addr */
*buf = ipa_write_8(38, *buf);
*buf = ipa_write_32(attrib->u.v4.dst_addr_mask, *buf);
*buf = ipa_write_32(attrib->u.v4.dst_addr, *buf);
*buf = ipa_pad_to_32(*buf);
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_SRC_PORT) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
IPAERR("ran out of ihl_rng16 eq\n");
@ -2074,6 +2105,36 @@ int ipa_generate_flt_eq(enum ipa_ip_type ip,
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IP_TYPE) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
IPAERR("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
/* 22 => offset of inner IP type after v6 header */
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].offset = 22;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].mask =
0xF0000000;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].value =
(u32)attrib->type << 24;
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IPV4_DST_ADDR) {
if (ipa_ihl_ofst_meq32[ihl_ofst_meq32] == -1) {
IPAERR("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= ipa_ihl_ofst_meq32[ihl_ofst_meq32];
/* 38 => offset of inner IPv4 addr */
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].offset = 38;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].mask =
attrib->u.v4.dst_addr_mask;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].value =
attrib->u.v4.dst_addr;
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_SRC_PORT) {
if (ipa_ihl_ofst_rng16[ihl_ofst_rng16] == -1) {
IPAERR_RL("ran out of ihl_rng16 eq\n");

View file

@ -511,6 +511,15 @@ static int ipa3_attrib_dump(struct ipa_rule_attrib *attrib,
if (attrib->attrib_mask & IPA_FLT_TCP_SYN_L2TP)
pr_err("tcp syn l2tp ");
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IP_TYPE)
pr_err("l2tp inner ip type: %d ", attrib->type);
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IPV4_DST_ADDR) {
addr[0] = htonl(attrib->u.v4.dst_addr);
mask[0] = htonl(attrib->u.v4.dst_addr_mask);
pr_err("dst_addr:%pI4 dst_addr_mask:%pI4 ", addr, mask);
}
pr_err("\n");
return 0;
}

View file

@ -1036,6 +1036,39 @@ static int ipa_fltrt_generate_hw_rule_bdy_ip6(u16 *en_rule,
ihl_ofst_meq32 += 2;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IP_TYPE) {
if (IPA_IS_RAN_OUT_OF_EQ(ipa3_0_ihl_ofst_meq32,
ihl_ofst_meq32)) {
IPAHAL_ERR("ran out of ihl_meq32 eq\n");
goto err;
}
*en_rule |= IPA_GET_RULE_EQ_BIT_PTRN(
ipa3_0_ihl_ofst_meq32[ihl_ofst_meq32]);
/* 22 => offset of IP type after v6 header */
extra = ipa_write_8(22, extra);
rest = ipa_write_32(0xF0000000, rest);
if (attrib->type == 0x40)
rest = ipa_write_32(0x40000000, rest);
else
rest = ipa_write_32(0x60000000, rest);
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IPV4_DST_ADDR) {
if (IPA_IS_RAN_OUT_OF_EQ(ipa3_0_ihl_ofst_meq32,
ihl_ofst_meq32)) {
IPAHAL_ERR("ran out of ihl_meq32 eq\n");
goto err;
}
*en_rule |= IPA_GET_RULE_EQ_BIT_PTRN(
ipa3_0_ihl_ofst_meq32[ihl_ofst_meq32]);
/* 38 => offset of inner IPv4 addr */
extra = ipa_write_8(38, extra);
rest = ipa_write_32(attrib->u.v4.dst_addr_mask, rest);
rest = ipa_write_32(attrib->u.v4.dst_addr, rest);
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_META_DATA) {
*en_rule |= IPA_GET_RULE_EQ_BIT_PTRN(IPA_METADATA_COMPARE);
rest = ipa_write_32(attrib->meta_data_mask, rest);
@ -2004,6 +2037,40 @@ static int ipa_flt_generate_eq_ip6(enum ipa_ip_type ip,
ihl_ofst_meq32 += 2;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IP_TYPE) {
if (IPA_IS_RAN_OUT_OF_EQ(ipa3_0_ihl_ofst_meq32,
ihl_ofst_meq32)) {
IPAHAL_ERR("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= IPA_GET_RULE_EQ_BIT_PTRN(
ipa3_0_ihl_ofst_meq32[ihl_ofst_meq32]);
/* 22 => offset of inner IP type after v6 header */
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].offset = 22;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].mask =
0xF0000000;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].value =
(u32)attrib->type << 24;
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_L2TP_INNER_IPV4_DST_ADDR) {
if (IPA_IS_RAN_OUT_OF_EQ(ipa3_0_ihl_ofst_meq32,
ihl_ofst_meq32)) {
IPAHAL_ERR("ran out of ihl_meq32 eq\n");
return -EPERM;
}
*en_rule |= IPA_GET_RULE_EQ_BIT_PTRN(
ipa3_0_ihl_ofst_meq32[ihl_ofst_meq32]);
/* 38 => offset of inner IPv4 addr */
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].offset = 38;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].mask =
attrib->u.v4.dst_addr_mask;
eq_atrb->ihl_offset_meq_32[ihl_ofst_meq32].value =
attrib->u.v4.dst_addr;
ihl_ofst_meq32++;
}
if (attrib->attrib_mask & IPA_FLT_MAC_ETHER_TYPE) {
if (IPA_IS_RAN_OUT_OF_EQ(ipa3_0_ofst_meq32, ofst_meq32)) {
IPAHAL_ERR("ran out of meq32 eq\n");

View file

@ -165,6 +165,8 @@
#define IPA_FLT_MAC_ETHER_TYPE (1ul << 21)
#define IPA_FLT_TCP_SYN (1ul << 23)
#define IPA_FLT_TCP_SYN_L2TP (1ul << 24)
#define IPA_FLT_L2TP_INNER_IP_TYPE (1ul << 25)
#define IPA_FLT_L2TP_INNER_IPV4_DST_ADDR (1ul << 26)
/**
* maximal number of NAT PDNs in the PDN config table