Lines Matching refs:cnp

73 static int cxgbit_np_hashfn(const struct cxgbit_np *cnp)
75 return ((unsigned long)cnp >> 10) & (NP_INFO_HASH_SIZE - 1);
79 cxgbit_np_hash_add(struct cxgbit_device *cdev, struct cxgbit_np *cnp,
85 int bucket = cxgbit_np_hashfn(cnp);
87 p->cnp = cnp;
99 cxgbit_np_hash_find(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
101 int stid = -1, bucket = cxgbit_np_hashfn(cnp);
106 if (p->cnp == cnp) {
116 static int cxgbit_np_hash_del(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
118 int stid = -1, bucket = cxgbit_np_hashfn(cnp);
123 if (p->cnp == cnp) {
137 struct cxgbit_np *cnp;
139 cnp = container_of(kref, struct cxgbit_np, kref);
140 kfree(cnp);
145 struct cxgbit_np *cnp)
148 &cnp->com.local_addr;
167 cxgbit_get_cnp(cnp);
168 cxgbit_init_wr_wait(&cnp->com.wr_wait);
175 ret = cxgbit_wait_for_reply(cdev, &cnp->com.wr_wait,
180 cxgbit_put_cnp(cnp);
197 struct cxgbit_np *cnp)
200 &cnp->com.local_addr;
206 cxgbit_get_cnp(cnp);
207 cxgbit_init_wr_wait(&cnp->com.wr_wait);
215 &cnp->com.wr_wait,
220 cxgbit_put_cnp(cnp);
290 static struct cxgbit_device *cxgbit_find_np_cdev(struct cxgbit_np *cnp)
292 struct sockaddr_storage *sockaddr = &cnp->com.local_addr;
318 static bool cxgbit_inaddr_any(struct cxgbit_np *cnp)
320 struct sockaddr_storage *sockaddr = &cnp->com.local_addr;
343 __cxgbit_setup_cdev_np(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
346 int ss_family = cnp->com.local_addr.ss_family;
351 stid = cxgb4_alloc_stid(cdev->lldi.tids, ss_family, cnp);
355 if (!cxgbit_np_hash_add(cdev, cnp, stid)) {
361 ret = cxgbit_create_server4(cdev, stid, cnp);
363 ret = cxgbit_create_server6(cdev, stid, cnp);
369 cxgbit_np_hash_del(cdev, cnp);
375 static int cxgbit_setup_cdev_np(struct cxgbit_np *cnp)
381 cdev = cxgbit_find_np_cdev(cnp);
385 if (cxgbit_np_hash_find(cdev, cnp) >= 0)
388 if (__cxgbit_setup_cdev_np(cdev, cnp))
391 cnp->com.cdev = cdev;
398 static int cxgbit_setup_all_np(struct cxgbit_np *cnp)
406 if (cxgbit_np_hash_find(cdev, cnp) >= 0) {
413 ret = __cxgbit_setup_cdev_np(cdev, cnp);
427 struct cxgbit_np *cnp;
434 cnp = kzalloc(sizeof(*cnp), GFP_KERNEL);
435 if (!cnp)
438 init_waitqueue_head(&cnp->accept_wait);
439 init_completion(&cnp->com.wr_wait.completion);
440 init_completion(&cnp->accept_comp);
441 INIT_LIST_HEAD(&cnp->np_accept_list);
442 spin_lock_init(&cnp->np_accept_lock);
443 kref_init(&cnp->kref);
446 memcpy(&cnp->com.local_addr, &np->np_sockaddr,
447 sizeof(cnp->com.local_addr));
449 cnp->np = np;
450 cnp->com.cdev = NULL;
452 if (cxgbit_inaddr_any(cnp))
453 ret = cxgbit_setup_all_np(cnp);
455 ret = cxgbit_setup_cdev_np(cnp);
458 cxgbit_put_cnp(cnp);
462 np->np_context = cnp;
463 cnp->com.state = CSK_STATE_LISTEN;
478 struct cxgbit_np *cnp = np->np_context;
483 ret = wait_for_completion_interruptible(&cnp->accept_comp);
498 spin_lock_bh(&cnp->np_accept_lock);
499 if (list_empty(&cnp->np_accept_list)) {
500 spin_unlock_bh(&cnp->np_accept_lock);
504 csk = list_first_entry(&cnp->np_accept_list,
509 spin_unlock_bh(&cnp->np_accept_lock);
518 __cxgbit_free_cdev_np(struct cxgbit_device *cdev, struct cxgbit_np *cnp)
523 stid = cxgbit_np_hash_del(cdev, cnp);
529 if (cnp->np->np_sockaddr.ss_family == AF_INET6)
532 cxgbit_get_cnp(cnp);
533 cxgbit_init_wr_wait(&cnp->com.wr_wait);
541 cxgbit_put_cnp(cnp);
545 ret = cxgbit_wait_for_reply(cdev, &cnp->com.wr_wait,
550 if (ipv6 && cnp->com.cdev) {
553 sin6 = (struct sockaddr_in6 *)&cnp->com.local_addr;
560 cnp->com.local_addr.ss_family);
564 static void cxgbit_free_all_np(struct cxgbit_np *cnp)
571 ret = __cxgbit_free_cdev_np(cdev, cnp);
578 static void cxgbit_free_cdev_np(struct cxgbit_np *cnp)
585 if (cdev == cnp->com.cdev) {
593 __cxgbit_free_cdev_np(cdev, cnp);
602 struct cxgbit_np *cnp = np->np_context;
605 cnp->com.state = CSK_STATE_DEAD;
606 if (cnp->com.cdev)
607 cxgbit_free_cdev_np(cnp);
609 cxgbit_free_all_np(cnp);
611 spin_lock_bh(&cnp->np_accept_lock);
612 list_for_each_entry_safe(csk, tmp, &cnp->np_accept_list, accept_node) {
616 spin_unlock_bh(&cnp->np_accept_lock);
619 cxgbit_put_cnp(cnp);
821 cxgbit_put_cnp(csk->cnp);
1220 struct cxgbit_np *cnp;
1237 cnp = lookup_stid(t, stid);
1238 if (!cnp) {
1244 if (cnp->com.state != CSK_STATE_LISTEN) {
1264 , __func__, cnp, tid,
1275 , __func__, cnp, tid,
1283 &cnp->com.local_addr)->sin6_scope_id);
1319 csk->cnp = cnp;
1372 cxgbit_get_cnp(cnp);
1584 struct cxgbit_np *cnp = lookup_stid(t, stid);
1586 pr_debug("%s: cnp = %p; stid = %u; status = %d\n",
1587 __func__, cnp, stid, rpl->status);
1589 if (!cnp) {
1594 cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status);
1595 cxgbit_put_cnp(cnp);
1606 struct cxgbit_np *cnp = lookup_stid(t, stid);
1608 pr_debug("%s: cnp = %p; stid = %u; status = %d\n",
1609 __func__, cnp, stid, rpl->status);
1611 if (!cnp) {
1616 cxgbit_wake_up(&cnp->com.wr_wait, __func__, rpl->status);
1617 cxgbit_put_cnp(cnp);
1629 struct cxgbit_np *cnp;
1639 cnp = csk->cnp;
1641 pr_debug("%s: csk %p; tid %u; cnp %p\n",
1642 __func__, csk, tid, cnp);
1654 spin_lock_bh(&cnp->np_accept_lock);
1655 list_add_tail(&csk->accept_node, &cnp->np_accept_list);
1656 spin_unlock_bh(&cnp->np_accept_lock);
1657 complete(&cnp->accept_comp);