From owner-svn-src-projects@freebsd.org Tue Sep 29 22:33:28 2015 Return-Path: Delivered-To: svn-src-projects@mailman.ysv.freebsd.org Received: from mx1.freebsd.org (mx1.freebsd.org [IPv6:2001:1900:2254:206a::19:1]) by mailman.ysv.freebsd.org (Postfix) with ESMTP id 0F5CCA0BDCD for ; Tue, 29 Sep 2015 22:33:28 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org (repo.freebsd.org [IPv6:2001:1900:2254:2068::e6a:0]) (using TLSv1.2 with cipher ECDHE-RSA-AES256-GCM-SHA384 (256/256 bits)) (Client did not present a certificate) by mx1.freebsd.org (Postfix) with ESMTPS id F15F21F9D; Tue, 29 Sep 2015 22:33:27 +0000 (UTC) (envelope-from np@FreeBSD.org) Received: from repo.freebsd.org ([127.0.1.70]) by repo.freebsd.org (8.15.2/8.15.2) with ESMTP id t8TMXR2r017568; Tue, 29 Sep 2015 22:33:27 GMT (envelope-from np@FreeBSD.org) Received: (from np@localhost) by repo.freebsd.org (8.15.2/8.15.2/Submit) id t8TMXR2G017566; Tue, 29 Sep 2015 22:33:27 GMT (envelope-from np@FreeBSD.org) Message-Id: <201509292233.t8TMXR2G017566@repo.freebsd.org> X-Authentication-Warning: repo.freebsd.org: np set sender to np@FreeBSD.org using -f From: Navdeep Parhar Date: Tue, 29 Sep 2015 22:33:27 +0000 (UTC) To: src-committers@freebsd.org, svn-src-projects@freebsd.org Subject: svn commit: r288404 - projects/cxl_iscsi/sys/dev/cxgbe/cxgbei X-SVN-Group: projects MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit X-BeenThere: svn-src-projects@freebsd.org X-Mailman-Version: 2.1.20 Precedence: list List-Id: "SVN commit messages for the src " projects" tree" List-Unsubscribe: , List-Archive: List-Post: List-Help: List-Subscribe: , X-List-Received-Date: Tue, 29 Sep 2015 22:33:28 -0000 Author: np Date: Tue Sep 29 22:33:26 2015 New Revision: 288404 URL: https://svnweb.freebsd.org/changeset/base/288404 Log: - Allocate more space than needed for icl_conn and icl_pdu. The extra space will be used for driver specific items. - Do not use the same name as icl_soft for the PDU zone. Modified: projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.h projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Modified: projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.h ============================================================================== --- projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.h Tue Sep 29 22:00:03 2015 (r288403) +++ projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/cxgbei.h Tue Sep 29 22:33:26 2015 (r288404) @@ -1,9 +1,7 @@ /*- - * Copyright (c) 2012 Chelsio Communications, Inc. + * Copyright (c) 2012, 2015 Chelsio Communications, Inc. * All rights reserved. * - * Chelsio T5xx iSCSI driver - * * Redistribution and use in source and binary forms, with or without * modification, are permitted provided that the following conditions * are met: @@ -29,6 +27,8 @@ #ifndef __CXGBEI_OFLD_H__ #define __CXGBEI_OFLD_H__ +#include + struct iscsi_socket { u_char s_dcrc_len; void *s_conn; /* ic_conn pointer */ @@ -52,6 +52,20 @@ struct iscsi_socket { struct mbuf *mbuf_ulp_ldata; }; +struct icl_cxgbei_conn { + struct icl_conn ic; + + /* cxgbei specific stuff goes here. */ + uint32_t icc_signature; +}; + +struct icl_cxgbei_pdu { + struct icl_pdu ip; + + /* cxgbei specific stuff goes here. */ + uint32_t icp_signature; +}; + struct cxgbei_sgl { int sg_flag; void *sg_addr; @@ -123,9 +137,6 @@ struct cxgbei_data { struct cxgbei_ulp2_tag_format tag_format; }; -struct icl_conn; -struct icl_pdu; - struct ulp_mbuf_cb *get_ulp_mbuf_cb(struct mbuf *); int cxgbei_conn_handoff(struct icl_conn *); int cxgbei_conn_close(struct icl_conn *); Modified: projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c ============================================================================== --- projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue Sep 29 22:00:03 2015 (r288403) +++ projects/cxl_iscsi/sys/dev/cxgbe/cxgbei/icl_cxgbei.c Tue Sep 29 22:33:26 2015 (r288404) @@ -1,5 +1,6 @@ /*- * Copyright (c) 2012 The FreeBSD Foundation + * Copyright (c) 2015 Chelsio Communications, Inc. * All rights reserved. * * This software was developed by Edward Tomasz Napierala under sponsorship @@ -83,7 +84,7 @@ static int recvspace = 1048576; SYSCTL_INT(_kern_icl_cxgbei, OID_AUTO, recvspace, CTLFLAG_RWTUN, &recvspace, 0, "Default receive socket buffer size"); -static uma_zone_t icl_pdu_zone; +static uma_zone_t icl_cxgbei_pdu_zone; static uma_zone_t icl_transfer_zone; static volatile u_int icl_cxgbei_ncons; @@ -126,28 +127,32 @@ static kobj_method_t icl_cxgbei_methods[ { 0, 0 } }; -DEFINE_CLASS(icl_cxgbei, icl_cxgbei_methods, sizeof(struct icl_conn)); +DEFINE_CLASS(icl_cxgbei, icl_cxgbei_methods, sizeof(struct icl_cxgbei_conn)); struct icl_pdu * icl_pdu_new_empty(struct icl_conn *ic, int flags); void icl_pdu_free(struct icl_pdu *ip); +#define CXGBEI_PDU_SIGNATURE 0x12344321 + struct icl_pdu * icl_pdu_new_empty(struct icl_conn *ic, int flags) { + struct icl_cxgbei_pdu *icp; struct icl_pdu *ip; #ifdef DIAGNOSTIC refcount_acquire(&ic->ic_outstanding_pdus); #endif - ip = uma_zalloc(icl_pdu_zone, flags | M_ZERO); - if (ip == NULL) { - ICL_WARN("failed to allocate %zd bytes", sizeof(*ip)); + icp = uma_zalloc(icl_cxgbei_pdu_zone, flags | M_ZERO); + if (icp == NULL) { #ifdef DIAGNOSTIC refcount_release(&ic->ic_outstanding_pdus); #endif return (NULL); } + icp->icp_signature = CXGBEI_PDU_SIGNATURE; + ip = &icp->ip; ip->ip_conn = ic; return (ip); @@ -157,13 +162,16 @@ void icl_pdu_free(struct icl_pdu *ip) { struct icl_conn *ic; + struct icl_cxgbei_pdu *icp; + icp = (void *)ip; + MPASS(icp->icp_signature == CXGBEI_PDU_SIGNATURE); ic = ip->ip_conn; m_freem(ip->ip_bhs_mbuf); m_freem(ip->ip_ahs_mbuf); m_freem(ip->ip_data_mbuf); - uma_zfree(icl_pdu_zone, ip); + uma_zfree(icl_cxgbei_pdu_zone, ip); #ifdef DIAGNOSTIC refcount_release(&ic->ic_outstanding_pdus); #endif @@ -411,15 +419,21 @@ icl_cxgbei_conn_pdu_queue(struct icl_con icl_pdu_queue(ip); } +#define CXGBEI_CONN_SIGNATURE 0x56788765 + static struct icl_conn * icl_cxgbei_new_conn(const char *name, struct mtx *lock) { + struct icl_cxgbei_conn *icc; struct icl_conn *ic; refcount_acquire(&icl_cxgbei_ncons); - ic = (struct icl_conn *)kobj_create(&icl_cxgbei_class, M_CXGBE, M_WAITOK | M_ZERO); + icc = (struct icl_cxgbei_conn *)kobj_create(&icl_cxgbei_class, M_CXGBE, + M_WAITOK | M_ZERO); + icc->icc_signature = CXGBEI_CONN_SIGNATURE; + ic = &icc->ic; STAILQ_INIT(&ic->ic_to_send); ic->ic_lock = lock; cv_init(&ic->ic_send_cv, "icl_cxgbei_tx"); @@ -437,10 +451,13 @@ icl_cxgbei_new_conn(const char *name, st void icl_cxgbei_conn_free(struct icl_conn *ic) { + struct icl_cxgbei_conn *icc = (void *)ic; + + MPASS(icc->icc_signature == CXGBEI_CONN_SIGNATURE); cv_destroy(&ic->ic_send_cv); cv_destroy(&ic->ic_receive_cv); - kobj_delete((struct kobj *)ic, M_CXGBE); + kobj_delete((struct kobj *)icc, M_CXGBE); refcount_release(&icl_cxgbei_ncons); } @@ -740,8 +757,8 @@ icl_cxgbei_load(void) { int error; - icl_pdu_zone = uma_zcreate("icl_pdu", - sizeof(struct icl_pdu), NULL, NULL, NULL, NULL, + icl_cxgbei_pdu_zone = uma_zcreate("icl_cxgbei_pdu", + sizeof(struct icl_cxgbei_pdu), NULL, NULL, NULL, NULL, UMA_ALIGN_PTR, 0); icl_transfer_zone = uma_zcreate("icl_transfer", 16 * 1024, NULL, NULL, NULL, NULL, @@ -749,12 +766,8 @@ icl_cxgbei_load(void) refcount_init(&icl_cxgbei_ncons, 0); - /* - * The reason we call this "none" is that to the user, - * it's known as "offload driver"; "offload driver: soft" - * doesn't make much sense. - */ - error = icl_register("cxgbei", 100, icl_cxgbei_limits, icl_cxgbei_new_conn); + error = icl_register("cxgbei", 100, icl_cxgbei_limits, + icl_cxgbei_new_conn); KASSERT(error == 0, ("failed to register")); return (error); @@ -769,7 +782,7 @@ icl_cxgbei_unload(void) icl_unregister("cxgbei"); - uma_zdestroy(icl_pdu_zone); + uma_zdestroy(icl_cxgbei_pdu_zone); uma_zdestroy(icl_transfer_zone); return (0);