Commit 7ecdfc34 authored by Jamal Hadi Salim's avatar Jamal Hadi Salim Committed by David S. Miller

[PKT_SCHED]: Fix pkt_cls.h incompatabilities.

Signed-off-by: default avatarJamal Hadi Salim <hadi@cyberus.ca>
Signed-off-by: default avatarDavid S. Miller <davem@redhat.com>
parent 8c714b07
...@@ -117,17 +117,6 @@ enum ...@@ -117,17 +117,6 @@ enum
struct tc_police struct tc_police
{ {
__u32 index; __u32 index;
#ifdef CONFIG_NET_CLS_ACT
int refcnt;
int bindcnt;
#endif
/* Turned off because it requires new tc
* to work (for now maintain ABI)
*
#ifdef CONFIG_NET_CLS_ACT
__u32 capab;
#endif
*/
int action; int action;
#define TC_POLICE_UNSPEC TC_ACT_UNSPEC #define TC_POLICE_UNSPEC TC_ACT_UNSPEC
#define TC_POLICE_OK TC_ACT_OK #define TC_POLICE_OK TC_ACT_OK
...@@ -140,6 +129,9 @@ struct tc_police ...@@ -140,6 +129,9 @@ struct tc_police
__u32 mtu; __u32 mtu;
struct tc_ratespec rate; struct tc_ratespec rate;
struct tc_ratespec peakrate; struct tc_ratespec peakrate;
int refcnt;
int bindcnt;
__u32 capab;
}; };
struct tcf_t struct tcf_t
...@@ -195,12 +187,9 @@ enum ...@@ -195,12 +187,9 @@ enum
TCA_U32_DIVISOR, TCA_U32_DIVISOR,
TCA_U32_SEL, TCA_U32_SEL,
TCA_U32_POLICE, TCA_U32_POLICE,
#ifdef CONFIG_NET_CLS_ACT
TCA_U32_ACT, TCA_U32_ACT,
#endif
#ifdef CONFIG_NET_CLS_IND
TCA_U32_INDEV, TCA_U32_INDEV,
#endif TCA_U32_PCNT,
__TCA_U32_MAX __TCA_U32_MAX
}; };
...@@ -212,9 +201,6 @@ struct tc_u32_key ...@@ -212,9 +201,6 @@ struct tc_u32_key
__u32 val; __u32 val;
int off; int off;
int offmask; int offmask;
#ifdef CONFIG_CLS_U32_PERF
unsigned long kcnt;
#endif
}; };
struct tc_u32_sel struct tc_u32_sel
...@@ -229,13 +215,17 @@ struct tc_u32_sel ...@@ -229,13 +215,17 @@ struct tc_u32_sel
short hoff; short hoff;
__u32 hmask; __u32 hmask;
#ifdef CONFIG_CLS_U32_PERF
unsigned long rcnt;
unsigned long rhit;
#endif
struct tc_u32_key keys[0]; struct tc_u32_key keys[0];
}; };
#ifdef CONFIG_CLS_U32_PERF
struct tc_u32_pcnt
{
__u64 rcnt;
__u64 rhit;
__u64 kcnts[0];
};
#endif
/* Flags */ /* Flags */
#define TC_U32_TERMINAL 1 #define TC_U32_TERMINAL 1
...@@ -300,12 +290,8 @@ enum ...@@ -300,12 +290,8 @@ enum
TCA_FW_UNSPEC, TCA_FW_UNSPEC,
TCA_FW_CLASSID, TCA_FW_CLASSID,
TCA_FW_POLICE, TCA_FW_POLICE,
#ifdef CONFIG_NET_CLS_IND TCA_FW_INDEV, /* used by CONFIG_NET_CLS_IND */
TCA_FW_INDEV, TCA_FW_ACT, /* used by CONFIG_NET_CLS_ACT */
#endif
#ifdef CONFIG_NET_CLS_ACT
TCA_FW_ACT,
#endif
__TCA_FW_MAX __TCA_FW_MAX
}; };
......
...@@ -64,17 +64,20 @@ struct tc_u_knode ...@@ -64,17 +64,20 @@ struct tc_u_knode
struct tc_u_hnode *ht_up; struct tc_u_hnode *ht_up;
#ifdef CONFIG_NET_CLS_ACT #ifdef CONFIG_NET_CLS_ACT
struct tc_action *action; struct tc_action *action;
#ifdef CONFIG_NET_CLS_IND
char indev[IFNAMSIZ];
#endif
#else #else
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
struct tcf_police *police; struct tcf_police *police;
#endif #endif
#endif
#ifdef CONFIG_NET_CLS_IND
char indev[IFNAMSIZ];
#endif #endif
u8 fshift; u8 fshift;
struct tcf_result res; struct tcf_result res;
struct tc_u_hnode *ht_down; struct tc_u_hnode *ht_down;
#ifdef CONFIG_CLS_U32_PERF
struct tc_u32_pcnt *pf;
#endif
struct tc_u32_sel sel; struct tc_u32_sel sel;
}; };
...@@ -120,6 +123,9 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re ...@@ -120,6 +123,9 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re
int sdepth = 0; int sdepth = 0;
int off2 = 0; int off2 = 0;
int sel = 0; int sel = 0;
#ifdef CONFIG_CLS_U32_PERF
int j;
#endif
int i; int i;
next_ht: next_ht:
...@@ -130,7 +136,8 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re ...@@ -130,7 +136,8 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re
struct tc_u32_key *key = n->sel.keys; struct tc_u32_key *key = n->sel.keys;
#ifdef CONFIG_CLS_U32_PERF #ifdef CONFIG_CLS_U32_PERF
n->sel.rcnt +=1; n->pf->rcnt +=1;
j = 0;
#endif #endif
for (i = n->sel.nkeys; i>0; i--, key++) { for (i = n->sel.nkeys; i>0; i--, key++) {
...@@ -139,7 +146,8 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re ...@@ -139,7 +146,8 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re
goto next_knode; goto next_knode;
} }
#ifdef CONFIG_CLS_U32_PERF #ifdef CONFIG_CLS_U32_PERF
key->kcnt +=1; n->pf->kcnts[j] +=1;
j++;
#endif #endif
} }
if (n->ht_down == NULL) { if (n->ht_down == NULL) {
...@@ -147,7 +155,6 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re ...@@ -147,7 +155,6 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re
if (n->sel.flags&TC_U32_TERMINAL) { if (n->sel.flags&TC_U32_TERMINAL) {
*res = n->res; *res = n->res;
#ifdef CONFIG_NET_CLS_ACT
#ifdef CONFIG_NET_CLS_IND #ifdef CONFIG_NET_CLS_IND
/* yes, i know it sucks but the feature is /* yes, i know it sucks but the feature is
** optional dammit! - JHS */ ** optional dammit! - JHS */
...@@ -164,8 +171,9 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re ...@@ -164,8 +171,9 @@ static int u32_classify(struct sk_buff *skb, struct tcf_proto *tp, struct tcf_re
} }
#endif #endif
#ifdef CONFIG_CLS_U32_PERF #ifdef CONFIG_CLS_U32_PERF
n->sel.rhit +=1; n->pf->rhit +=1;
#endif #endif
#ifdef CONFIG_NET_CLS_ACT
if (n->action) { if (n->action) {
int pol_res = tcf_action_exec(skb, n->action); int pol_res = tcf_action_exec(skb, n->action);
if (skb->tc_classid > 0) { if (skb->tc_classid > 0) {
...@@ -358,6 +366,10 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n) ...@@ -358,6 +366,10 @@ static int u32_destroy_key(struct tcf_proto *tp, struct tc_u_knode *n)
#endif #endif
if (n->ht_down) if (n->ht_down)
n->ht_down->refcnt--; n->ht_down->refcnt--;
#ifdef CONFIG_CLS_U32_PERF
if (n && (NULL != n->pf))
kfree(n->pf);
#endif
kfree(n); kfree(n);
return 0; return 0;
} }
...@@ -571,18 +583,6 @@ static int u32_set_parms(struct Qdisc *q, unsigned long base, ...@@ -571,18 +583,6 @@ static int u32_set_parms(struct Qdisc *q, unsigned long base,
tcf_action_destroy(act, TCA_ACT_UNBIND); tcf_action_destroy(act, TCA_ACT_UNBIND);
} }
#ifdef CONFIG_NET_CLS_IND
n->indev[0] = 0;
if(tb[TCA_U32_INDEV-1]) {
struct rtattr *input_dev = tb[TCA_U32_INDEV-1];
if (RTA_PAYLOAD(input_dev) >= IFNAMSIZ) {
printk("cls_u32: bad indev name %s\n",(char*)RTA_DATA(input_dev));
/* should we clear state first? */
return -EINVAL;
}
sprintf(n->indev, "%s", (char*)RTA_DATA(input_dev));
}
#endif
#else #else
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
...@@ -594,6 +594,19 @@ static int u32_set_parms(struct Qdisc *q, unsigned long base, ...@@ -594,6 +594,19 @@ static int u32_set_parms(struct Qdisc *q, unsigned long base,
tcf_police_release(police, TCA_ACT_UNBIND); tcf_police_release(police, TCA_ACT_UNBIND);
} }
#endif #endif
#endif
#ifdef CONFIG_NET_CLS_IND
n->indev[0] = 0;
if(tb[TCA_U32_INDEV-1]) {
struct rtattr *input_dev = tb[TCA_U32_INDEV-1];
if (RTA_PAYLOAD(input_dev) >= IFNAMSIZ) {
printk("cls_u32: bad indev name %s\n",(char*)RTA_DATA(input_dev));
/* should we clear state first? */
return -EINVAL;
}
sprintf(n->indev, "%s", (char*)RTA_DATA(input_dev));
printk("got IND %s\n",n->indev);
}
#endif #endif
return 0; return 0;
...@@ -682,17 +695,20 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, ...@@ -682,17 +695,20 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
s = RTA_DATA(tb[TCA_U32_SEL-1]); s = RTA_DATA(tb[TCA_U32_SEL-1]);
#ifdef CONFIG_CLS_U32_PERF
if (RTA_PAYLOAD(tb[TCA_U32_SEL-1]) <
(s->nkeys*sizeof(struct tc_u32_key)) + sizeof(struct tc_u32_sel)) {
printk("Please upgrade your iproute2 tools or compile proper options in!\n");
return -EINVAL;
}
#endif
n = kmalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL); n = kmalloc(sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key), GFP_KERNEL);
if (n == NULL) if (n == NULL)
return -ENOBUFS; return -ENOBUFS;
memset(n, 0, sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key)); memset(n, 0, sizeof(*n) + s->nkeys*sizeof(struct tc_u32_key));
#ifdef CONFIG_CLS_U32_PERF
n->pf = kmalloc(sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(__u64), GFP_KERNEL);
if (n->pf == NULL) {
kfree(n);
return -ENOBUFS;
}
memset(n->pf, 0, sizeof(struct tc_u32_pcnt) + s->nkeys*sizeof(__u64));
#endif
memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key)); memcpy(&n->sel, s, sizeof(*s) + s->nkeys*sizeof(struct tc_u32_key));
n->ht_up = ht; n->ht_up = ht;
n->handle = handle; n->handle = handle;
...@@ -721,6 +737,10 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle, ...@@ -721,6 +737,10 @@ static int u32_change(struct tcf_proto *tp, unsigned long base, u32 handle,
*arg = (unsigned long)n; *arg = (unsigned long)n;
return 0; return 0;
} }
#ifdef CONFIG_CLS_U32_PERF
if (n && (NULL != n->pf))
kfree(n->pf);
#endif
kfree(n); kfree(n);
return err; return err;
} }
...@@ -812,13 +832,6 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -812,13 +832,6 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
p_rta->rta_len = skb->tail - (u8*)p_rta; p_rta->rta_len = skb->tail - (u8*)p_rta;
} }
#ifdef CONFIG_NET_CLS_IND
if(strlen(n->indev)) {
struct rtattr * p_rta = (struct rtattr*)skb->tail;
RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev);
p_rta->rta_len = skb->tail - (u8*)p_rta;
}
#endif
#else #else
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
...@@ -833,14 +846,29 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh, ...@@ -833,14 +846,29 @@ static int u32_dump(struct tcf_proto *tp, unsigned long fh,
} }
#endif #endif
#endif
#ifdef CONFIG_NET_CLS_IND
if(strlen(n->indev)) {
struct rtattr * p_rta = (struct rtattr*)skb->tail;
RTA_PUT(skb, TCA_U32_INDEV, IFNAMSIZ, n->indev);
p_rta->rta_len = skb->tail - (u8*)p_rta;
}
#endif
#ifdef CONFIG_CLS_U32_PERF
RTA_PUT(skb, TCA_U32_PCNT,
sizeof(struct tc_u32_pcnt) + n->sel.nkeys*sizeof(__u64),
n->pf);
#endif #endif
} }
rta->rta_len = skb->tail - b; rta->rta_len = skb->tail - b;
#ifdef CONFIG_NET_CLS_ACT #ifdef CONFIG_NET_CLS_ACT
if (TC_U32_KEY(n->handle) && n->action && n->action->type == TCA_OLD_COMPAT) { if (TC_U32_KEY(n->handle) != 0) {
if (tcf_action_copy_stats(skb,n->action)) if (TC_U32_KEY(n->handle) && n->action && n->action->type == TCA_OLD_COMPAT) {
goto rtattr_failure; if (tcf_action_copy_stats(skb,n->action))
goto rtattr_failure;
}
} }
#else #else
#ifdef CONFIG_NET_CLS_POLICE #ifdef CONFIG_NET_CLS_POLICE
...@@ -875,6 +903,19 @@ static struct tcf_proto_ops cls_u32_ops = { ...@@ -875,6 +903,19 @@ static struct tcf_proto_ops cls_u32_ops = {
static int __init init_u32(void) static int __init init_u32(void)
{ {
printk("u32 classifier\n");
#ifdef CONFIG_CLS_U32_PERF
printk(" Perfomance counters on\n");
#endif
#ifdef CONFIG_NET_CLS_POLICE
printk(" OLD policer on \n");
#endif
#ifdef CONFIG_NET_CLS_IND
printk(" input device check on \n");
#endif
#ifdef CONFIG_NET_CLS_ACT
printk(" Actions configured \n");
#endif
return register_tcf_proto_ops(&cls_u32_ops); return register_tcf_proto_ops(&cls_u32_ops);
} }
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment