2 * Shared Memory Communications over RDMA (SMC-R) and RoCE
4 * AF_SMC protocol family socket handler keeping the AF_INET sock address type
5 * applies to SOCK_STREAM sockets only
6 * offers an alternative communication option for TCP-protocol sockets
7 * applicable with RoCE-cards only
9 * Initial restrictions:
10 * - non-blocking connect postponed
11 * - IPv6 support postponed
12 * - support for alternate links postponed
13 * - partial support for non-blocking sockets only
14 * - support for urgent data postponed
16 * Copyright IBM Corp. 2016
18 * Author(s): Ursula Braun <ubraun@linux.vnet.ibm.com>
19 * based on prototype from Frank Blaschka
22 #define KMSG_COMPONENT "smc"
23 #define pr_fmt(fmt) KMSG_COMPONENT ": " fmt
25 #include <linux/module.h>
26 #include <linux/socket.h>
27 #include <linux/inetdevice.h>
28 #include <linux/workqueue.h>
37 static void smc_tcp_listen_work(struct work_struct *);
39 static void smc_set_keepalive(struct sock *sk, int val)
41 struct smc_sock *smc = smc_sk(sk);
43 smc->clcsock->sk->sk_prot->keepalive(smc->clcsock->sk, val);
46 static struct proto smc_proto = {
49 .keepalive = smc_set_keepalive,
50 .obj_size = sizeof(struct smc_sock),
51 .slab_flags = SLAB_DESTROY_BY_RCU,
54 static int smc_release(struct socket *sock)
56 struct sock *sk = sock->sk;
65 sk->sk_state = SMC_CLOSED;
67 sock_release(smc->clcsock);
81 static void smc_destruct(struct sock *sk)
83 if (sk->sk_state != SMC_CLOSED)
85 if (!sock_flag(sk, SOCK_DEAD))
88 sk_refcnt_debug_dec(sk);
91 static struct sock *smc_sock_alloc(struct net *net, struct socket *sock)
96 sk = sk_alloc(net, PF_SMC, GFP_KERNEL, &smc_proto, 0);
100 sock_init_data(sock, sk); /* sets sk_refcnt to 1 */
101 sk->sk_state = SMC_INIT;
102 sk->sk_destruct = smc_destruct;
103 sk->sk_protocol = SMCPROTO_SMC;
105 INIT_WORK(&smc->tcp_listen_work, smc_tcp_listen_work);
106 INIT_LIST_HEAD(&smc->accept_q);
107 spin_lock_init(&smc->accept_q_lock);
108 sk_refcnt_debug_inc(sk);
113 static int smc_bind(struct socket *sock, struct sockaddr *uaddr,
116 struct sockaddr_in *addr = (struct sockaddr_in *)uaddr;
117 struct sock *sk = sock->sk;
118 struct smc_sock *smc;
123 /* replicate tests from inet_bind(), to be safe wrt. future changes */
125 if (addr_len < sizeof(struct sockaddr_in))
129 /* accept AF_UNSPEC (mapped to AF_INET) only if s_addr is INADDR_ANY */
130 if ((addr->sin_family != AF_INET) &&
131 ((addr->sin_family != AF_UNSPEC) ||
132 (addr->sin_addr.s_addr != htonl(INADDR_ANY))))
137 /* Check if socket is already active */
139 if (sk->sk_state != SMC_INIT)
142 smc->clcsock->sk->sk_reuse = sk->sk_reuse;
143 rc = kernel_bind(smc->clcsock, uaddr, addr_len);
151 static void smc_copy_sock_settings(struct sock *nsk, struct sock *osk,
154 /* options we don't get control via setsockopt for */
155 nsk->sk_type = osk->sk_type;
156 nsk->sk_sndbuf = osk->sk_sndbuf;
157 nsk->sk_rcvbuf = osk->sk_rcvbuf;
158 nsk->sk_sndtimeo = osk->sk_sndtimeo;
159 nsk->sk_rcvtimeo = osk->sk_rcvtimeo;
160 nsk->sk_mark = osk->sk_mark;
161 nsk->sk_priority = osk->sk_priority;
162 nsk->sk_rcvlowat = osk->sk_rcvlowat;
163 nsk->sk_bound_dev_if = osk->sk_bound_dev_if;
164 nsk->sk_err = osk->sk_err;
166 nsk->sk_flags &= ~mask;
167 nsk->sk_flags |= osk->sk_flags & mask;
170 #define SK_FLAGS_SMC_TO_CLC ((1UL << SOCK_URGINLINE) | \
171 (1UL << SOCK_KEEPOPEN) | \
172 (1UL << SOCK_LINGER) | \
173 (1UL << SOCK_BROADCAST) | \
174 (1UL << SOCK_TIMESTAMP) | \
175 (1UL << SOCK_DBG) | \
176 (1UL << SOCK_RCVTSTAMP) | \
177 (1UL << SOCK_RCVTSTAMPNS) | \
178 (1UL << SOCK_LOCALROUTE) | \
179 (1UL << SOCK_TIMESTAMPING_RX_SOFTWARE) | \
180 (1UL << SOCK_RXQ_OVFL) | \
181 (1UL << SOCK_WIFI_STATUS) | \
182 (1UL << SOCK_NOFCS) | \
183 (1UL << SOCK_FILTER_LOCKED))
184 /* copy only relevant settings and flags of SOL_SOCKET level from smc to
185 * clc socket (since smc is not called for these options from net/core)
187 static void smc_copy_sock_settings_to_clc(struct smc_sock *smc)
189 smc_copy_sock_settings(smc->clcsock->sk, &smc->sk, SK_FLAGS_SMC_TO_CLC);
192 #define SK_FLAGS_CLC_TO_SMC ((1UL << SOCK_URGINLINE) | \
193 (1UL << SOCK_KEEPOPEN) | \
194 (1UL << SOCK_LINGER) | \
196 /* copy only settings and flags relevant for smc from clc to smc socket */
197 static void smc_copy_sock_settings_to_smc(struct smc_sock *smc)
199 smc_copy_sock_settings(&smc->sk, smc->clcsock->sk, SK_FLAGS_CLC_TO_SMC);
202 /* determine subnet and mask of internal TCP socket */
203 int smc_netinfo_by_tcpsk(struct socket *clcsock,
204 __be32 *subnet, u8 *prefix_len)
206 struct dst_entry *dst = sk_dst_get(clcsock->sk);
207 struct sockaddr_in addr;
220 /* get address to which the internal TCP socket is bound */
221 kernel_getsockname(clcsock, (struct sockaddr *)&addr, &len);
222 /* analyze IPv4 specific data of net_device belonging to TCP socket */
223 for_ifa(dst->dev->ip_ptr) {
224 if (ifa->ifa_address != addr.sin_addr.s_addr)
226 *prefix_len = inet_mask_len(ifa->ifa_mask);
227 *subnet = ifa->ifa_address & ifa->ifa_mask;
230 } endfor_ifa(dst->dev->ip_ptr);
238 /* setup for RDMA connection of client */
239 static int smc_connect_rdma(struct smc_sock *smc)
241 struct smc_clc_msg_accept_confirm aclc;
242 struct smc_ib_device *smcibdev;
247 /* IPSec connections opt out of SMC-R optimizations */
248 if (using_ipsec(smc)) {
249 reason_code = SMC_CLC_DECL_IPSEC;
253 /* PNET table look up: search active ib_device and port
254 * within same PNETID that also contains the ethernet device
255 * used for the internal TCP socket
257 smc_pnet_find_roce_resource(smc->clcsock->sk, &smcibdev, &ibport);
259 reason_code = SMC_CLC_DECL_CNFERR; /* configuration error */
263 /* do inband token exchange */
264 reason_code = smc_clc_send_proposal(smc, smcibdev, ibport);
265 if (reason_code < 0) {
269 if (reason_code > 0) /* configuration error */
271 /* receive SMC Accept CLC message */
272 reason_code = smc_clc_wait_msg(smc, &aclc, sizeof(aclc),
274 if (reason_code < 0) {
281 /* tbd in follow-on patch: more steps to setup RDMA communcication,
282 * create connection, link group, link
285 /* tbd in follow-on patch: more steps to setup RDMA communcication,
286 * create rmbs, map rmbs, rtoken_handling, modify_qp
289 rc = smc_clc_send_confirm(smc);
293 /* tbd in follow-on patch: llc_confirm */
296 smc_copy_sock_settings_to_clc(smc);
297 smc->sk.sk_state = SMC_ACTIVE;
302 /* RDMA setup failed, switch back to TCP */
303 smc->use_fallback = true;
304 if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) {
305 rc = smc_clc_send_decline(smc, reason_code, 0);
306 if (rc < sizeof(struct smc_clc_msg_decline))
315 static int smc_connect(struct socket *sock, struct sockaddr *addr,
318 struct sock *sk = sock->sk;
319 struct smc_sock *smc;
324 /* separate smc parameter checking to be safe */
325 if (alen < sizeof(addr->sa_family))
327 if (addr->sa_family != AF_INET)
329 smc->addr = addr; /* needed for nonblocking connect */
332 switch (sk->sk_state) {
343 smc_copy_sock_settings_to_clc(smc);
344 rc = kernel_connect(smc->clcsock, addr, alen, flags);
348 /* setup RDMA connection */
349 rc = smc_connect_rdma(smc);
353 rc = 0; /* success cases including fallback */
361 static int smc_clcsock_accept(struct smc_sock *lsmc, struct smc_sock **new_smc)
363 struct sock *sk = &lsmc->sk;
364 struct socket *new_clcsock;
368 release_sock(&lsmc->sk);
369 new_sk = smc_sock_alloc(sock_net(sk), NULL);
372 lsmc->sk.sk_err = ENOMEM;
374 lock_sock(&lsmc->sk);
377 *new_smc = smc_sk(new_sk);
379 rc = kernel_accept(lsmc->clcsock, &new_clcsock, 0);
380 lock_sock(&lsmc->sk);
382 lsmc->sk.sk_err = -rc;
383 new_sk->sk_state = SMC_CLOSED;
384 sock_set_flag(new_sk, SOCK_DEAD);
389 if (lsmc->sk.sk_state == SMC_CLOSED) {
391 sock_release(new_clcsock);
392 new_sk->sk_state = SMC_CLOSED;
393 sock_set_flag(new_sk, SOCK_DEAD);
399 (*new_smc)->clcsock = new_clcsock;
404 /* add a just created sock to the accept queue of the listen sock as
405 * candidate for a following socket accept call from user space
407 static void smc_accept_enqueue(struct sock *parent, struct sock *sk)
409 struct smc_sock *par = smc_sk(parent);
412 spin_lock(&par->accept_q_lock);
413 list_add_tail(&smc_sk(sk)->accept_q, &par->accept_q);
414 spin_unlock(&par->accept_q_lock);
415 sk_acceptq_added(parent);
418 /* remove a socket from the accept queue of its parental listening socket */
419 static void smc_accept_unlink(struct sock *sk)
421 struct smc_sock *par = smc_sk(sk)->listen_smc;
423 spin_lock(&par->accept_q_lock);
424 list_del_init(&smc_sk(sk)->accept_q);
425 spin_unlock(&par->accept_q_lock);
426 sk_acceptq_removed(&smc_sk(sk)->listen_smc->sk);
430 /* remove a sock from the accept queue to bind it to a new socket created
431 * for a socket accept call from user space
433 static struct sock *smc_accept_dequeue(struct sock *parent,
434 struct socket *new_sock)
436 struct smc_sock *isk, *n;
439 list_for_each_entry_safe(isk, n, &smc_sk(parent)->accept_q, accept_q) {
440 new_sk = (struct sock *)isk;
442 smc_accept_unlink(new_sk);
443 if (new_sk->sk_state == SMC_CLOSED) {
444 /* tbd in follow-on patch: close this sock */
448 sock_graft(new_sk, new_sock);
454 /* clean up for a created but never accepted sock */
455 static void smc_close_non_accepted(struct sock *sk)
457 struct smc_sock *smc = smc_sk(sk);
467 /* more closing stuff to be added with socket closing patch */
471 /* setup for RDMA connection of server */
472 static void smc_listen_work(struct work_struct *work)
474 struct smc_sock *new_smc = container_of(work, struct smc_sock,
476 struct socket *newclcsock = new_smc->clcsock;
477 struct smc_sock *lsmc = new_smc->listen_smc;
478 struct smc_clc_msg_accept_confirm cclc;
479 struct sock *newsmcsk = &new_smc->sk;
480 struct smc_clc_msg_proposal pclc;
481 struct smc_ib_device *smcibdev;
482 struct sockaddr_in peeraddr;
489 /* do inband token exchange -
490 *wait for and receive SMC Proposal CLC message
492 reason_code = smc_clc_wait_msg(new_smc, &pclc, sizeof(pclc),
499 /* IPSec connections opt out of SMC-R optimizations */
500 if (using_ipsec(new_smc)) {
501 reason_code = SMC_CLC_DECL_IPSEC;
505 /* PNET table look up: search active ib_device and port
506 * within same PNETID that also contains the ethernet device
507 * used for the internal TCP socket
509 smc_pnet_find_roce_resource(newclcsock->sk, &smcibdev, &ibport);
511 reason_code = SMC_CLC_DECL_CNFERR; /* configuration error */
515 /* determine subnet and mask from internal TCP socket */
516 rc = smc_netinfo_by_tcpsk(newclcsock, &subnet, &prefix_len);
518 reason_code = SMC_CLC_DECL_CNFERR; /* configuration error */
521 if ((pclc.outgoing_subnet != subnet) ||
522 (pclc.prefix_len != prefix_len)) {
523 reason_code = SMC_CLC_DECL_CNFERR; /* configuration error */
527 /* get address of the peer connected to the internal TCP socket */
528 kernel_getpeername(newclcsock, (struct sockaddr *)&peeraddr, &len);
530 /* tbd in follow-on patch: more steps to setup RDMA communcication,
531 * create connection, link_group, link
534 /* tbd in follow-on patch: more steps to setup RDMA communcication,
535 * create rmbs, map rmbs
538 rc = smc_clc_send_accept(new_smc);
542 /* receive SMC Confirm CLC message */
543 reason_code = smc_clc_wait_msg(new_smc, &cclc, sizeof(cclc),
550 /* tbd in follow-on patch: more steps to setup RDMA communcication,
551 * rtoken_handling, modify_qp
555 sk_refcnt_debug_inc(newsmcsk);
556 newsmcsk->sk_state = SMC_ACTIVE;
558 lock_sock(&lsmc->sk);
559 if (lsmc->sk.sk_state == SMC_LISTEN) {
560 smc_accept_enqueue(&lsmc->sk, newsmcsk);
561 } else { /* no longer listening */
562 smc_close_non_accepted(newsmcsk);
564 release_sock(&lsmc->sk);
567 lsmc->sk.sk_data_ready(&lsmc->sk);
568 sock_put(&lsmc->sk); /* sock_hold in smc_tcp_listen_work */
572 /* RDMA setup failed, switch back to TCP */
573 new_smc->use_fallback = true;
574 if (reason_code && (reason_code != SMC_CLC_DECL_REPLY)) {
575 rc = smc_clc_send_decline(new_smc, reason_code, 0);
576 if (rc < sizeof(struct smc_clc_msg_decline))
582 newsmcsk->sk_state = SMC_CLOSED;
583 goto enqueue; /* queue new sock with sk_err set */
586 static void smc_tcp_listen_work(struct work_struct *work)
588 struct smc_sock *lsmc = container_of(work, struct smc_sock,
590 struct smc_sock *new_smc;
593 lock_sock(&lsmc->sk);
594 while (lsmc->sk.sk_state == SMC_LISTEN) {
595 rc = smc_clcsock_accept(lsmc, &new_smc);
601 new_smc->listen_smc = lsmc;
602 new_smc->use_fallback = false; /* assume rdma capability first*/
603 sock_hold(&lsmc->sk); /* sock_put in smc_listen_work */
604 INIT_WORK(&new_smc->smc_listen_work, smc_listen_work);
605 smc_copy_sock_settings_to_smc(new_smc);
606 schedule_work(&new_smc->smc_listen_work);
610 release_sock(&lsmc->sk);
611 lsmc->sk.sk_data_ready(&lsmc->sk); /* no more listening, wake accept */
614 static int smc_listen(struct socket *sock, int backlog)
616 struct sock *sk = sock->sk;
617 struct smc_sock *smc;
624 if ((sk->sk_state != SMC_INIT) && (sk->sk_state != SMC_LISTEN))
628 if (sk->sk_state == SMC_LISTEN) {
629 sk->sk_max_ack_backlog = backlog;
632 /* some socket options are handled in core, so we could not apply
633 * them to the clc socket -- copy smc socket options to clc socket
635 smc_copy_sock_settings_to_clc(smc);
637 rc = kernel_listen(smc->clcsock, backlog);
640 sk->sk_max_ack_backlog = backlog;
641 sk->sk_ack_backlog = 0;
642 sk->sk_state = SMC_LISTEN;
643 INIT_WORK(&smc->tcp_listen_work, smc_tcp_listen_work);
644 schedule_work(&smc->tcp_listen_work);
651 static int smc_accept(struct socket *sock, struct socket *new_sock,
654 struct sock *sk = sock->sk, *nsk;
655 DECLARE_WAITQUEUE(wait, current);
656 struct smc_sock *lsmc;
663 if (lsmc->sk.sk_state != SMC_LISTEN) {
668 /* Wait for an incoming connection */
669 timeo = sock_rcvtimeo(sk, flags & O_NONBLOCK);
670 add_wait_queue_exclusive(sk_sleep(sk), &wait);
671 while (!(nsk = smc_accept_dequeue(sk, new_sock))) {
672 set_current_state(TASK_INTERRUPTIBLE);
678 timeo = schedule_timeout(timeo);
679 /* wakeup by sk_data_ready in smc_listen_work() */
680 sched_annotate_sleep();
682 if (signal_pending(current)) {
683 rc = sock_intr_errno(timeo);
687 set_current_state(TASK_RUNNING);
688 remove_wait_queue(sk_sleep(sk), &wait);
691 rc = sock_error(nsk);
698 static int smc_getname(struct socket *sock, struct sockaddr *addr,
701 struct smc_sock *smc;
703 if (peer && (sock->sk->sk_state != SMC_ACTIVE))
706 smc = smc_sk(sock->sk);
708 return smc->clcsock->ops->getname(smc->clcsock, addr, len, peer);
711 static int smc_sendmsg(struct socket *sock, struct msghdr *msg, size_t len)
713 struct sock *sk = sock->sk;
714 struct smc_sock *smc;
719 if (sk->sk_state != SMC_ACTIVE)
721 if (smc->use_fallback)
722 rc = smc->clcsock->ops->sendmsg(smc->clcsock, msg, len);
724 rc = sock_no_sendmsg(sock, msg, len);
730 static int smc_recvmsg(struct socket *sock, struct msghdr *msg, size_t len,
733 struct sock *sk = sock->sk;
734 struct smc_sock *smc;
739 if ((sk->sk_state != SMC_ACTIVE) && (sk->sk_state != SMC_CLOSED))
742 if (smc->use_fallback)
743 rc = smc->clcsock->ops->recvmsg(smc->clcsock, msg, len, flags);
745 rc = sock_no_recvmsg(sock, msg, len, flags);
751 static unsigned int smc_accept_poll(struct sock *parent)
753 struct smc_sock *isk;
757 list_for_each_entry(isk, &smc_sk(parent)->accept_q, accept_q) {
758 sk = (struct sock *)isk;
760 if (sk->sk_state == SMC_ACTIVE) {
761 release_sock(parent);
762 return POLLIN | POLLRDNORM;
765 release_sock(parent);
770 static unsigned int smc_poll(struct file *file, struct socket *sock,
773 struct sock *sk = sock->sk;
774 unsigned int mask = 0;
775 struct smc_sock *smc;
778 smc = smc_sk(sock->sk);
779 if ((sk->sk_state == SMC_INIT) || smc->use_fallback) {
780 /* delegate to CLC child sock */
781 mask = smc->clcsock->ops->poll(file, smc->clcsock, wait);
782 /* if non-blocking connect finished ... */
784 if ((sk->sk_state == SMC_INIT) && (mask & POLLOUT)) {
785 sk->sk_err = smc->clcsock->sk->sk_err;
789 rc = smc_connect_rdma(smc);
793 /* success cases including fallback */
794 mask |= POLLOUT | POLLWRNORM;
799 sock_poll_wait(file, sk_sleep(sk), wait);
800 if (sk->sk_state == SMC_LISTEN)
801 /* woken up by sk_data_ready in smc_listen_work() */
802 mask |= smc_accept_poll(sk);
805 /* for now - to be enhanced in follow-on patch */
811 static int smc_shutdown(struct socket *sock, int how)
813 struct sock *sk = sock->sk;
814 struct smc_sock *smc;
819 if ((how < SHUT_RD) || (how > SHUT_RDWR))
825 if (sk->sk_state == SMC_CLOSED)
827 if (smc->use_fallback) {
828 rc = kernel_sock_shutdown(smc->clcsock, how);
829 sk->sk_shutdown = smc->clcsock->sk->sk_shutdown;
830 if (sk->sk_shutdown == SHUTDOWN_MASK)
831 sk->sk_state = SMC_CLOSED;
833 rc = sock_no_shutdown(sock, how);
843 static int smc_setsockopt(struct socket *sock, int level, int optname,
844 char __user *optval, unsigned int optlen)
846 struct sock *sk = sock->sk;
847 struct smc_sock *smc;
851 /* generic setsockopts reaching us here always apply to the
854 return smc->clcsock->ops->setsockopt(smc->clcsock, level, optname,
858 static int smc_getsockopt(struct socket *sock, int level, int optname,
859 char __user *optval, int __user *optlen)
861 struct smc_sock *smc;
863 smc = smc_sk(sock->sk);
864 /* socket options apply to the CLC socket */
865 return smc->clcsock->ops->getsockopt(smc->clcsock, level, optname,
869 static int smc_ioctl(struct socket *sock, unsigned int cmd,
872 struct smc_sock *smc;
874 smc = smc_sk(sock->sk);
875 if (smc->use_fallback)
876 return smc->clcsock->ops->ioctl(smc->clcsock, cmd, arg);
878 return sock_no_ioctl(sock, cmd, arg);
881 static ssize_t smc_sendpage(struct socket *sock, struct page *page,
882 int offset, size_t size, int flags)
884 struct sock *sk = sock->sk;
885 struct smc_sock *smc;
890 if (sk->sk_state != SMC_ACTIVE)
892 if (smc->use_fallback)
893 rc = kernel_sendpage(smc->clcsock, page, offset,
896 rc = sock_no_sendpage(sock, page, offset, size, flags);
903 static ssize_t smc_splice_read(struct socket *sock, loff_t *ppos,
904 struct pipe_inode_info *pipe, size_t len,
907 struct sock *sk = sock->sk;
908 struct smc_sock *smc;
913 if ((sk->sk_state != SMC_ACTIVE) && (sk->sk_state != SMC_CLOSED))
915 if (smc->use_fallback) {
916 rc = smc->clcsock->ops->splice_read(smc->clcsock, ppos,
926 /* must look like tcp */
927 static const struct proto_ops smc_sock_ops = {
929 .owner = THIS_MODULE,
930 .release = smc_release,
932 .connect = smc_connect,
933 .socketpair = sock_no_socketpair,
934 .accept = smc_accept,
935 .getname = smc_getname,
938 .listen = smc_listen,
939 .shutdown = smc_shutdown,
940 .setsockopt = smc_setsockopt,
941 .getsockopt = smc_getsockopt,
942 .sendmsg = smc_sendmsg,
943 .recvmsg = smc_recvmsg,
944 .mmap = sock_no_mmap,
945 .sendpage = smc_sendpage,
946 .splice_read = smc_splice_read,
949 static int smc_create(struct net *net, struct socket *sock, int protocol,
952 struct smc_sock *smc;
956 rc = -ESOCKTNOSUPPORT;
957 if (sock->type != SOCK_STREAM)
960 rc = -EPROTONOSUPPORT;
961 if ((protocol != IPPROTO_IP) && (protocol != IPPROTO_TCP))
965 sock->ops = &smc_sock_ops;
966 sk = smc_sock_alloc(net, sock);
970 /* create internal TCP socket for CLC handshake and fallback */
972 smc->use_fallback = false; /* assume rdma capability first */
973 rc = sock_create_kern(net, PF_INET, SOCK_STREAM,
974 IPPROTO_TCP, &smc->clcsock);
976 sk_common_release(sk);
982 static const struct net_proto_family smc_sock_family_ops = {
984 .owner = THIS_MODULE,
985 .create = smc_create,
988 static int __init smc_init(void)
992 rc = smc_pnet_init();
996 rc = proto_register(&smc_proto, 1);
998 pr_err("%s: proto_register fails with %d\n", __func__, rc);
1002 rc = sock_register(&smc_sock_family_ops);
1004 pr_err("%s: sock_register fails with %d\n", __func__, rc);
1008 rc = smc_ib_register_client();
1010 pr_err("%s: ib_register fails with %d\n", __func__, rc);
1017 sock_unregister(PF_SMC);
1019 proto_unregister(&smc_proto);
1025 static void __exit smc_exit(void)
1027 smc_ib_unregister_client();
1028 sock_unregister(PF_SMC);
1029 proto_unregister(&smc_proto);
1033 module_init(smc_init);
1034 module_exit(smc_exit);
1036 MODULE_AUTHOR("Ursula Braun <ubraun@linux.vnet.ibm.com>");
1037 MODULE_DESCRIPTION("smc socket address family");
1038 MODULE_LICENSE("GPL");
1039 MODULE_ALIAS_NETPROTO(PF_SMC);