Lines Matching refs:gtp

105 static struct pdp_ctx *gtp0_pdp_find(struct gtp_dev *gtp, u64 tid)  in gtp0_pdp_find()  argument
110 head = &gtp->tid_hash[gtp0_hashfn(tid) % gtp->hash_size]; in gtp0_pdp_find()
121 static struct pdp_ctx *gtp1_pdp_find(struct gtp_dev *gtp, u32 tid) in gtp1_pdp_find() argument
126 head = &gtp->tid_hash[gtp1u_hashfn(tid) % gtp->hash_size]; in gtp1_pdp_find()
137 static struct pdp_ctx *ipv4_pdp_find(struct gtp_dev *gtp, __be32 ms_addr) in ipv4_pdp_find() argument
142 head = &gtp->addr_hash[ipv4_hashfn(ms_addr) % gtp->hash_size]; in ipv4_pdp_find()
212 static int gtp0_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) in gtp0_udp_encap_recv() argument
230 pctx = gtp0_pdp_find(gtp, be64_to_cpu(gtp0->tid)); in gtp0_udp_encap_recv()
232 netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); in gtp0_udp_encap_recv()
236 return gtp_rx(pctx, skb, hdrlen, gtp->role); in gtp0_udp_encap_recv()
239 static int gtp1u_udp_encap_recv(struct gtp_dev *gtp, struct sk_buff *skb) in gtp1u_udp_encap_recv() argument
272 pctx = gtp1_pdp_find(gtp, ntohl(gtp1->tid)); in gtp1u_udp_encap_recv()
274 netdev_dbg(gtp->dev, "No PDP ctx to decap skb=%p\n", skb); in gtp1u_udp_encap_recv()
278 return gtp_rx(pctx, skb, hdrlen, gtp->role); in gtp1u_udp_encap_recv()
283 struct gtp_dev *gtp; in __gtp_encap_destroy() local
286 gtp = sk->sk_user_data; in __gtp_encap_destroy()
287 if (gtp) { in __gtp_encap_destroy()
288 if (gtp->sk0 == sk) in __gtp_encap_destroy()
289 gtp->sk0 = NULL; in __gtp_encap_destroy()
291 gtp->sk1u = NULL; in __gtp_encap_destroy()
314 static void gtp_encap_disable(struct gtp_dev *gtp) in gtp_encap_disable() argument
316 gtp_encap_disable_sock(gtp->sk0); in gtp_encap_disable()
317 gtp_encap_disable_sock(gtp->sk1u); in gtp_encap_disable()
325 struct gtp_dev *gtp; in gtp_encap_recv() local
328 gtp = rcu_dereference_sk_user_data(sk); in gtp_encap_recv()
329 if (!gtp) in gtp_encap_recv()
332 netdev_dbg(gtp->dev, "encap_recv sk=%p\n", sk); in gtp_encap_recv()
336 netdev_dbg(gtp->dev, "received GTP0 packet\n"); in gtp_encap_recv()
337 ret = gtp0_udp_encap_recv(gtp, skb); in gtp_encap_recv()
340 netdev_dbg(gtp->dev, "received GTP1U packet\n"); in gtp_encap_recv()
341 ret = gtp1u_udp_encap_recv(gtp, skb); in gtp_encap_recv()
349 netdev_dbg(gtp->dev, "pass up to the process\n"); in gtp_encap_recv()
354 netdev_dbg(gtp->dev, "GTP packet has been dropped\n"); in gtp_encap_recv()
365 struct gtp_dev *gtp = netdev_priv(dev); in gtp_dev_init() local
367 gtp->dev = dev; in gtp_dev_init()
378 struct gtp_dev *gtp = netdev_priv(dev); in gtp_dev_uninit() local
380 gtp_encap_disable(gtp); in gtp_dev_uninit()
479 struct gtp_dev *gtp = netdev_priv(dev); in gtp_build_skb_ip4() local
491 if (gtp->role == GTP_ROLE_SGSN) in gtp_build_skb_ip4()
492 pctx = ipv4_pdp_find(gtp, iph->saddr); in gtp_build_skb_ip4()
494 pctx = ipv4_pdp_find(gtp, iph->daddr); in gtp_build_skb_ip4()
636 static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize);
637 static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]);
641 struct gtp_dev *gtp = netdev_priv(dev); in gtp_destructor() local
643 kfree(gtp->addr_hash); in gtp_destructor()
644 kfree(gtp->tid_hash); in gtp_destructor()
651 struct gtp_dev *gtp; in gtp_newlink() local
658 gtp = netdev_priv(dev); in gtp_newlink()
668 err = gtp_hashtable_new(gtp, hashsize); in gtp_newlink()
672 err = gtp_encap_enable(gtp, data); in gtp_newlink()
683 list_add_rcu(&gtp->list, &gn->gtp_dev_list); in gtp_newlink()
691 gtp_encap_disable(gtp); in gtp_newlink()
693 kfree(gtp->addr_hash); in gtp_newlink()
694 kfree(gtp->tid_hash); in gtp_newlink()
700 struct gtp_dev *gtp = netdev_priv(dev); in gtp_dellink() local
704 for (i = 0; i < gtp->hash_size; i++) in gtp_dellink()
705 hlist_for_each_entry_rcu(pctx, &gtp->tid_hash[i], hlist_tid) in gtp_dellink()
708 list_del_rcu(&gtp->list); in gtp_dellink()
735 struct gtp_dev *gtp = netdev_priv(dev); in gtp_fill_info() local
737 if (nla_put_u32(skb, IFLA_GTP_PDP_HASHSIZE, gtp->hash_size)) in gtp_fill_info()
759 static int gtp_hashtable_new(struct gtp_dev *gtp, int hsize) in gtp_hashtable_new() argument
763 gtp->addr_hash = kmalloc_array(hsize, sizeof(struct hlist_head), in gtp_hashtable_new()
765 if (gtp->addr_hash == NULL) in gtp_hashtable_new()
768 gtp->tid_hash = kmalloc_array(hsize, sizeof(struct hlist_head), in gtp_hashtable_new()
770 if (gtp->tid_hash == NULL) in gtp_hashtable_new()
773 gtp->hash_size = hsize; in gtp_hashtable_new()
776 INIT_HLIST_HEAD(&gtp->addr_hash[i]); in gtp_hashtable_new()
777 INIT_HLIST_HEAD(&gtp->tid_hash[i]); in gtp_hashtable_new()
781 kfree(gtp->addr_hash); in gtp_hashtable_new()
786 struct gtp_dev *gtp) in gtp_encap_enable_socket() argument
818 tuncfg.sk_user_data = gtp; in gtp_encap_enable_socket()
832 static int gtp_encap_enable(struct gtp_dev *gtp, struct nlattr *data[]) in gtp_encap_enable() argument
841 sk0 = gtp_encap_enable_socket(fd0, UDP_ENCAP_GTP0, gtp); in gtp_encap_enable()
849 sk1u = gtp_encap_enable_socket(fd1, UDP_ENCAP_GTP1U, gtp); in gtp_encap_enable()
865 gtp->sk0 = sk0; in gtp_encap_enable()
866 gtp->sk1u = sk1u; in gtp_encap_enable()
867 gtp->role = role; in gtp_encap_enable()
874 struct gtp_dev *gtp = NULL; in gtp_find_dev() local
892 gtp = netdev_priv(dev); in gtp_find_dev()
895 return gtp; in gtp_find_dev()
925 static struct pdp_ctx *gtp_pdp_add(struct gtp_dev *gtp, struct sock *sk, in gtp_pdp_add() argument
929 struct net_device *dev = gtp->dev; in gtp_pdp_add()
936 hash_ms = ipv4_hashfn(ms_addr) % gtp->hash_size; in gtp_pdp_add()
939 pctx = ipv4_pdp_find(gtp, ms_addr); in gtp_pdp_add()
943 pctx_tid = gtp0_pdp_find(gtp, in gtp_pdp_add()
946 pctx_tid = gtp1_pdp_find(gtp, in gtp_pdp_add()
981 pctx->dev = gtp->dev; in gtp_pdp_add()
992 hash_tid = gtp0_hashfn(pctx->u.v0.tid) % gtp->hash_size; in gtp_pdp_add()
995 hash_tid = gtp1u_hashfn(pctx->u.v1.i_tei) % gtp->hash_size; in gtp_pdp_add()
999 hlist_add_head_rcu(&pctx->hlist_addr, &gtp->addr_hash[hash_ms]); in gtp_pdp_add()
1000 hlist_add_head_rcu(&pctx->hlist_tid, &gtp->tid_hash[hash_tid]); in gtp_pdp_add()
1039 struct gtp_dev *gtp; in gtp_genl_new_pdp() local
1069 gtp = gtp_find_dev(sock_net(skb->sk), info->attrs); in gtp_genl_new_pdp()
1070 if (!gtp) { in gtp_genl_new_pdp()
1076 sk = gtp->sk0; in gtp_genl_new_pdp()
1078 sk = gtp->sk1u; in gtp_genl_new_pdp()
1087 pctx = gtp_pdp_add(gtp, sk, info); in gtp_genl_new_pdp()
1103 struct gtp_dev *gtp; in gtp_find_pdp_by_link() local
1105 gtp = gtp_find_dev(net, nla); in gtp_find_pdp_by_link()
1106 if (!gtp) in gtp_find_pdp_by_link()
1112 return ipv4_pdp_find(gtp, ip); in gtp_find_pdp_by_link()
1117 return gtp0_pdp_find(gtp, nla_get_u64(nla[GTPA_TID])); in gtp_find_pdp_by_link()
1119 return gtp1_pdp_find(gtp, nla_get_u32(nla[GTPA_I_TEI])); in gtp_find_pdp_by_link()
1279 struct gtp_dev *last_gtp = (struct gtp_dev *)cb->args[2], *gtp; in gtp_genl_dump_pdp() local
1291 list_for_each_entry_rcu(gtp, &gn->gtp_dev_list, list) { in gtp_genl_dump_pdp()
1292 if (last_gtp && last_gtp != gtp) in gtp_genl_dump_pdp()
1297 for (i = bucket; i < gtp->hash_size; i++) { in gtp_genl_dump_pdp()
1299 hlist_for_each_entry_rcu(pctx, &gtp->tid_hash[i], in gtp_genl_dump_pdp()
1309 cb->args[2] = (unsigned long)gtp; in gtp_genl_dump_pdp()
1383 struct gtp_dev *gtp; in gtp_net_exit() local
1387 list_for_each_entry(gtp, &gn->gtp_dev_list, list) in gtp_net_exit()
1388 gtp_dellink(gtp->dev, &list); in gtp_net_exit()