The branch main has been updated by jhb:

URL: 
https://cgit.FreeBSD.org/src/commit/?id=43d5661a9d0f44c73344e0f2fc094b7286987313

commit 43d5661a9d0f44c73344e0f2fc094b7286987313
Author:     John Baldwin <[email protected]>
AuthorDate: 2022-04-18 19:50:20 +0000
Commit:     John Baldwin <[email protected]>
CommitDate: 2022-04-18 19:53:33 +0000

    cxgbei: Return limits for the specific adapter the socket is on.
    
    Reviewed by:    mav
    Sponsored by:   Chelsio Communications
    Differential Revision:  https://reviews.freebsd.org/D34929
---
 sys/dev/cxgbe/cxgbei/icl_cxgbei.c | 66 +++++++++++++++++++++++++++++++++++++--
 1 file changed, 64 insertions(+), 2 deletions(-)

diff --git a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c 
b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
index f0189372bd03..f7b06a472200 100644
--- a/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
+++ b/sys/dev/cxgbe/cxgbei/icl_cxgbei.c
@@ -1745,6 +1745,7 @@ icl_cxgbei_conn_transfer_done(struct icl_conn *ic, void 
*arg)
        }
 }
 
+#ifdef COMPAT_FREEBSD13
 static void
 cxgbei_limits(struct adapter *sc, void *arg)
 {
@@ -1771,6 +1772,62 @@ cxgbei_limits(struct adapter *sc, void *arg)
 
        end_synchronized_op(sc, LOCK_HELD);
 }
+#endif
+
+static int
+cxgbei_limits_fd(struct icl_drv_limits *idl, int fd)
+{
+       struct find_ofld_adapter_rr fa;
+       struct file *fp;
+       struct socket *so;
+       struct adapter *sc;
+       struct cxgbei_data *ci;
+       cap_rights_t rights;
+       int error;
+
+       error = fget(curthread, fd,
+           cap_rights_init_one(&rights, CAP_SOCK_CLIENT), &fp);
+       if (error != 0)
+               return (error);
+       if (fp->f_type != DTYPE_SOCKET) {
+               fdrop(fp, curthread);
+               return (EINVAL);
+       }
+       so = fp->f_data;
+       if (so->so_type != SOCK_STREAM ||
+           so->so_proto->pr_protocol != IPPROTO_TCP) {
+               fdrop(fp, curthread);
+               return (EINVAL);
+       }
+
+       /* Find the adapter offloading this socket. */
+       fa.sc = NULL;
+       fa.so = so;
+       t4_iterate(find_offload_adapter, &fa);
+       if (fa.sc == NULL) {
+               fdrop(fp, curthread);
+               return (ENXIO);
+       }
+       fdrop(fp, curthread);
+
+       sc = fa.sc;
+       error = begin_synchronized_op(sc, NULL, HOLD_LOCK, "t4lims");
+       if (error != 0)
+               return (error);
+
+       if (uld_active(sc, ULD_ISCSI)) {
+               ci = sc->iscsi_ulp_softc;
+               MPASS(ci != NULL);
+
+               idl->idl_max_recv_data_segment_length = ci->max_rx_data_len;
+               idl->idl_max_send_data_segment_length = ci->max_tx_data_len;
+       } else
+               error = ENXIO;
+
+       end_synchronized_op(sc, LOCK_HELD);
+
+       return (error);
+}
 
 static int
 icl_cxgbei_limits(struct icl_drv_limits *idl, int socket)
@@ -1784,9 +1841,14 @@ icl_cxgbei_limits(struct icl_drv_limits *idl, int socket)
        idl->idl_max_burst_length = max_burst_length;
        idl->idl_first_burst_length = first_burst_length;
 
-       t4_iterate(cxgbei_limits, idl);
+#ifdef COMPAT_FREEBSD13
+       if (socket == 0) {
+               t4_iterate(cxgbei_limits, idl);
+               return (0);
+       }
+#endif
 
-       return (0);
+       return (cxgbei_limits_fd(idl, socket));
 }
 
 int

Reply via email to