<div>Ping</div><div> </div><div>21.11.2022, 11:39, "Daniil Tatianin" <d-tatianin@yandex-team.ru>:</div><blockquote><p>cxgbit and libcxgbi both used the exact same function but with slightly<br />different names, and a missing NULL check in one case. Move the function<br />to libcxgb/libcxgb_ppm.c and nuke the duplicate.<br /><br />This also renames the function to cxgbi_ppm_set_one_ppod so that it<br />matches the rest of the functions in cxgb_ppm.<br /><br />Signed-off-by: Daniil Tatianin <<a href="mailto:d-tatianin@yandex-team.ru" rel="noopener noreferrer">d-tatianin@yandex-team.ru</a>><br />---<br /> .../ethernet/chelsio/libcxgb/libcxgb_ppm.c | 56 ++++++++++++++++++<br /> .../ethernet/chelsio/libcxgb/libcxgb_ppm.h | 5 ++<br /> drivers/scsi/cxgbi/cxgb3i/cxgb3i.c | 2 +-<br /> drivers/scsi/cxgbi/cxgb4i/cxgb4i.c | 2 +-<br /> drivers/scsi/cxgbi/libcxgbi.c | 55 ------------------<br /> drivers/scsi/cxgbi/libcxgbi.h | 3 -<br /> drivers/target/iscsi/cxgbit/cxgbit_ddp.c | 57 +------------------<br /> 7 files changed, 64 insertions(+), 116 deletions(-)<br /><br />diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c<br />index 854d87e1125c..9103826b0d27 100644<br />--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c<br />+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.c<br />@@ -527,6 +527,62 @@ unsigned int cxgbi_tagmask_set(unsigned int ppmax)<br /> }<br /> EXPORT_SYMBOL(cxgbi_tagmask_set);<br /> <br />+void<br />+cxgbi_ppm_set_one_ppod(struct cxgbi_pagepod *ppod,<br />+ struct cxgbi_task_tag_info *ttinfo,<br />+ struct scatterlist **sg_pp, unsigned int *sg_off)<br />+{<!-- --><br />+ struct scatterlist *sg = sg_pp ? *sg_pp : NULL;<br />+ unsigned int offset = sg_off ? *sg_off : 0;<br />+ dma_addr_t addr = 0UL;<br />+ unsigned int len = 0;<br />+ int i;<br />+<br />+ memcpy(ppod, &ttinfo->hdr, sizeof(struct cxgbi_pagepod_hdr));<br />+<br />+ if (sg) {<!-- --><br />+ addr = sg_dma_address(sg);<br />+ len = sg_dma_len(sg);<br />+ }<br />+<br />+ for (i = 0; i < PPOD_PAGES_MAX; i++) {<!-- --><br />+ if (sg) {<!-- --><br />+ ppod->addr[i] = cpu_to_be64(addr + offset);<br />+ offset += PAGE_SIZE;<br />+ if (offset == (len + sg->offset)) {<!-- --><br />+ offset = 0;<br />+ sg = sg_next(sg);<br />+ if (sg) {<!-- --><br />+ addr = sg_dma_address(sg);<br />+ len = sg_dma_len(sg);<br />+ }<br />+ }<br />+ } else {<!-- --><br />+ ppod->addr[i] = 0ULL;<br />+ }<br />+ }<br />+<br />+ /*<br />+ * the fifth address needs to be repeated in the next ppod, so do<br />+ * not move sg<br />+ */<br />+ if (sg_pp) {<!-- --><br />+ *sg_pp = sg;<br />+ *sg_off = offset;<br />+ }<br />+<br />+ if (offset == len) {<!-- --><br />+ offset = 0;<br />+ if (sg) {<!-- --><br />+ sg = sg_next(sg);<br />+ if (sg)<br />+ addr = sg_dma_address(sg);<br />+ }<br />+ }<br />+ ppod->addr[i] = sg ? cpu_to_be64(addr + offset) : 0ULL;<br />+}<br />+EXPORT_SYMBOL(cxgbi_ppm_set_one_ppod);<br />+<br /> MODULE_AUTHOR("Chelsio Communications");<br /> MODULE_DESCRIPTION("Chelsio common library");<br /> MODULE_LICENSE("Dual BSD/GPL");<br />diff --git a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.h b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.h<br />index 1b4156461ba1..f2178ee0b18a 100644<br />--- a/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.h<br />+++ b/drivers/net/ethernet/chelsio/libcxgb/libcxgb_ppm.h<br />@@ -332,4 +332,9 @@ int cxgbi_ppm_release(struct cxgbi_ppm *ppm);<br /> void cxgbi_tagmask_check(unsigned int tagmask, struct cxgbi_tag_format *);<br /> unsigned int cxgbi_tagmask_set(unsigned int ppmax);<br /> <br />+void<br />+cxgbi_ppm_set_one_ppod(struct cxgbi_pagepod *ppod,<br />+ struct cxgbi_task_tag_info *ttinfo,<br />+ struct scatterlist **sg_pp, unsigned int *sg_off);<br />+<br /> #endif /*__LIBCXGB_PPM_H__*/<br />diff --git a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c<br />index ff9d4287937a..0399e82362b7 100644<br />--- a/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c<br />+++ b/drivers/scsi/cxgbi/cxgb3i/cxgb3i.c<br />@@ -1115,7 +1115,7 @@ static int ddp_set_map(struct cxgbi_ppm *ppm, struct cxgbi_sock *csk,<br />                 req = (struct ulp_mem_io *)skb->head;<br />                 ppod = (struct cxgbi_pagepod *)(req + 1);<br />                 sg_off = i * PPOD_PAGES_MAX;<br />- cxgbi_ddp_set_one_ppod(ppod, ttinfo, &sg,<br />+ cxgbi_ppm_set_one_ppod(ppod, ttinfo, &sg,<br />                                        &sg_off);<br />                 skb->priority = CPL_PRIORITY_CONTROL;<br />                 cxgb3_ofld_send(ppm->lldev, skb);<br />diff --git a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c<br />index c07d2e3b4bcf..1f768cc3fbfb 100644<br />--- a/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c<br />+++ b/drivers/scsi/cxgbi/cxgb4i/cxgb4i.c<br />@@ -2035,7 +2035,7 @@ static int ddp_ppod_write_idata(struct cxgbi_ppm *ppm, struct cxgbi_sock *csk,<br />         ppod = (struct cxgbi_pagepod *)(idata + 1);<br /> <br />         for (i = 0; i < npods; i++, ppod++)<br />- cxgbi_ddp_set_one_ppod(ppod, ttinfo, sg_pp, sg_off);<br />+ cxgbi_ppm_set_one_ppod(ppod, ttinfo, sg_pp, sg_off);<br /> <br />         cxgbi_skcb_set_flag(skb, SKCBF_TX_MEM_WRITE);<br />         cxgbi_skcb_set_flag(skb, SKCBF_TX_FLAG_COMPL);<br />diff --git a/drivers/scsi/cxgbi/libcxgbi.c b/drivers/scsi/cxgbi/libcxgbi.c<br />index af281e271f88..6a2627a73f26 100644<br />--- a/drivers/scsi/cxgbi/libcxgbi.c<br />+++ b/drivers/scsi/cxgbi/libcxgbi.c<br />@@ -1151,61 +1151,6 @@ scmd_get_params(struct scsi_cmnd *sc, struct scatterlist **sgl,<br />         /* Caution: for protection sdb, sdb->length is invalid */<br /> }<br /> <br />-void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *ppod,<br />- struct cxgbi_task_tag_info *ttinfo,<br />- struct scatterlist **sg_pp, unsigned int *sg_off)<br />-{<!-- --><br />- struct scatterlist *sg = sg_pp ? *sg_pp : NULL;<br />- unsigned int offset = sg_off ? *sg_off : 0;<br />- dma_addr_t addr = 0UL;<br />- unsigned int len = 0;<br />- int i;<br />-<br />- memcpy(ppod, &ttinfo->hdr, sizeof(struct cxgbi_pagepod_hdr));<br />-<br />- if (sg) {<!-- --><br />- addr = sg_dma_address(sg);<br />- len = sg_dma_len(sg);<br />- }<br />-<br />- for (i = 0; i < PPOD_PAGES_MAX; i++) {<!-- --><br />- if (sg) {<!-- --><br />- ppod->addr[i] = cpu_to_be64(addr + offset);<br />- offset += PAGE_SIZE;<br />- if (offset == (len + sg->offset)) {<!-- --><br />- offset = 0;<br />- sg = sg_next(sg);<br />- if (sg) {<!-- --><br />- addr = sg_dma_address(sg);<br />- len = sg_dma_len(sg);<br />- }<br />- }<br />- } else {<!-- --><br />- ppod->addr[i] = 0ULL;<br />- }<br />- }<br />-<br />- /*<br />- * the fifth address needs to be repeated in the next ppod, so do<br />- * not move sg<br />- */<br />- if (sg_pp) {<!-- --><br />- *sg_pp = sg;<br />- *sg_off = offset;<br />- }<br />-<br />- if (offset == len) {<!-- --><br />- offset = 0;<br />- sg = sg_next(sg);<br />- if (sg) {<!-- --><br />- addr = sg_dma_address(sg);<br />- len = sg_dma_len(sg);<br />- }<br />- }<br />- ppod->addr[i] = sg ? cpu_to_be64(addr + offset) : 0ULL;<br />-}<br />-EXPORT_SYMBOL_GPL(cxgbi_ddp_set_one_ppod);<br />-<br /> /*<br />  * APIs interacting with open-iscsi libraries<br />  */<br />diff --git a/drivers/scsi/cxgbi/libcxgbi.h b/drivers/scsi/cxgbi/libcxgbi.h<br />index 3687b5c0cf90..f90e747bcb4f 100644<br />--- a/drivers/scsi/cxgbi/libcxgbi.h<br />+++ b/drivers/scsi/cxgbi/libcxgbi.h<br />@@ -636,9 +636,6 @@ int cxgbi_ddp_init(struct cxgbi_device *, unsigned int, unsigned int,<br />                         unsigned int, unsigned int);<br /> int cxgbi_ddp_cleanup(struct cxgbi_device *);<br /> void cxgbi_ddp_page_size_factor(int *);<br />-void cxgbi_ddp_set_one_ppod(struct cxgbi_pagepod *,<br />- struct cxgbi_task_tag_info *,<br />- struct scatterlist **sg_pp, unsigned int *sg_off);<br /> int cxgbi_ddp_ppm_setup(void **ppm_pp, struct cxgbi_device *cdev,<br />                         struct cxgbi_tag_format *tformat,<br />                         unsigned int iscsi_size, unsigned int llimit,<br />diff --git a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c<br />index 17fd0d8cc490..fe29f4962058 100644<br />--- a/drivers/target/iscsi/cxgbit/cxgbit_ddp.c<br />+++ b/drivers/target/iscsi/cxgbit/cxgbit_ddp.c<br />@@ -5,61 +5,6 @@<br /> <br /> #include "cxgbit.h"<br /> <br />-static void<br />-cxgbit_set_one_ppod(struct cxgbi_pagepod *ppod,<br />- struct cxgbi_task_tag_info *ttinfo,<br />- struct scatterlist **sg_pp, unsigned int *sg_off)<br />-{<!-- --><br />- struct scatterlist *sg = sg_pp ? *sg_pp : NULL;<br />- unsigned int offset = sg_off ? *sg_off : 0;<br />- dma_addr_t addr = 0UL;<br />- unsigned int len = 0;<br />- int i;<br />-<br />- memcpy(ppod, &ttinfo->hdr, sizeof(struct cxgbi_pagepod_hdr));<br />-<br />- if (sg) {<!-- --><br />- addr = sg_dma_address(sg);<br />- len = sg_dma_len(sg);<br />- }<br />-<br />- for (i = 0; i < PPOD_PAGES_MAX; i++) {<!-- --><br />- if (sg) {<!-- --><br />- ppod->addr[i] = cpu_to_be64(addr + offset);<br />- offset += PAGE_SIZE;<br />- if (offset == (len + sg->offset)) {<!-- --><br />- offset = 0;<br />- sg = sg_next(sg);<br />- if (sg) {<!-- --><br />- addr = sg_dma_address(sg);<br />- len = sg_dma_len(sg);<br />- }<br />- }<br />- } else {<!-- --><br />- ppod->addr[i] = 0ULL;<br />- }<br />- }<br />-<br />- /*<br />- * the fifth address needs to be repeated in the next ppod, so do<br />- * not move sg<br />- */<br />- if (sg_pp) {<!-- --><br />- *sg_pp = sg;<br />- *sg_off = offset;<br />- }<br />-<br />- if (offset == len) {<!-- --><br />- offset = 0;<br />- if (sg) {<!-- --><br />- sg = sg_next(sg);<br />- if (sg)<br />- addr = sg_dma_address(sg);<br />- }<br />- }<br />- ppod->addr[i] = sg ? cpu_to_be64(addr + offset) : 0ULL;<br />-}<br />-<br /> static struct sk_buff *<br /> cxgbit_ppod_init_idata(struct cxgbit_device *cdev, struct cxgbi_ppm *ppm,<br />                        unsigned int idx, unsigned int npods, unsigned int tid)<br />@@ -116,7 +61,7 @@ cxgbit_ppod_write_idata(struct cxgbi_ppm *ppm, struct cxgbit_sock *csk,<br />         ppod = (struct cxgbi_pagepod *)(idata + 1);<br /> <br />         for (i = 0; i < npods; i++, ppod++)<br />- cxgbit_set_one_ppod(ppod, ttinfo, sg_pp, sg_off);<br />+ cxgbi_ppm_set_one_ppod(ppod, ttinfo, sg_pp, sg_off);<br /> <br />         __skb_queue_tail(&csk->ppodq, skb);<br /> </p>--<br />2.25.1<br /> </blockquote>