Skip to content

Commit 4398888

Browse files
Wen GuPaolo Abeni
authored andcommitted
net/smc: add operations to merge sndbuf with peer DMB
In some scenarios using Emulated-ISM device, sndbuf can share the same physical memory region with peer DMB to avoid data copy from one side to the other. In such case the sndbuf is only a descriptor that describes the shared memory and does not actually occupy memory, it's more like a ghost buffer. +----------+ +----------+ | socket A | | socket B | +----------+ +----------+ | | +--------+ +--------+ | sndbuf | | DMB | | desc | | desc | +--------+ +--------+ | | | +----v-----+ +--------------------------> memory | +----------+ So here introduces three new SMC-D device operations to check if this feature is supported by device, and to {attach|detach} ghost sndbuf to peer DMB. For now only loopback-ism supports this. Signed-off-by: Wen Gu <guwen@linux.alibaba.com> Reviewed-by: Wenjia Zhang <wenjia@linux.ibm.com> Reviewed-and-tested-by: Jan Karcher <jaka@linux.ibm.com> Signed-off-by: Paolo Abeni <pabeni@redhat.com>
1 parent 0479134 commit 4398888

File tree

3 files changed

+47
-0
lines changed

3 files changed

+47
-0
lines changed

include/net/smc.h

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -74,6 +74,9 @@ struct smcd_ops {
7474
int (*reset_vlan_required)(struct smcd_dev *dev);
7575
int (*signal_event)(struct smcd_dev *dev, struct smcd_gid *rgid,
7676
u32 trigger_irq, u32 event_code, u64 info);
77+
int (*support_dmb_nocopy)(struct smcd_dev *dev);
78+
int (*attach_dmb)(struct smcd_dev *dev, struct smcd_dmb *dmb);
79+
int (*detach_dmb)(struct smcd_dev *dev, u64 token);
7780
};
7881

7982
struct smcd_dev {

net/smc/smc_ism.c

Lines changed: 40 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -250,6 +250,46 @@ int smc_ism_register_dmb(struct smc_link_group *lgr, int dmb_len,
250250
return rc;
251251
}
252252

253+
bool smc_ism_support_dmb_nocopy(struct smcd_dev *smcd)
254+
{
255+
/* for now only loopback-ism supports
256+
* merging sndbuf with peer DMB to avoid
257+
* data copies between them.
258+
*/
259+
return (smcd->ops->support_dmb_nocopy &&
260+
smcd->ops->support_dmb_nocopy(smcd));
261+
}
262+
263+
int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token,
264+
struct smc_buf_desc *dmb_desc)
265+
{
266+
struct smcd_dmb dmb;
267+
int rc = 0;
268+
269+
if (!dev->ops->attach_dmb)
270+
return -EINVAL;
271+
272+
memset(&dmb, 0, sizeof(dmb));
273+
dmb.dmb_tok = token;
274+
rc = dev->ops->attach_dmb(dev, &dmb);
275+
if (!rc) {
276+
dmb_desc->sba_idx = dmb.sba_idx;
277+
dmb_desc->token = dmb.dmb_tok;
278+
dmb_desc->cpu_addr = dmb.cpu_addr;
279+
dmb_desc->dma_addr = dmb.dma_addr;
280+
dmb_desc->len = dmb.dmb_len;
281+
}
282+
return rc;
283+
}
284+
285+
int smc_ism_detach_dmb(struct smcd_dev *dev, u64 token)
286+
{
287+
if (!dev->ops->detach_dmb)
288+
return -EINVAL;
289+
290+
return dev->ops->detach_dmb(dev, token);
291+
}
292+
253293
static int smc_nl_handle_smcd_dev(struct smcd_dev *smcd,
254294
struct sk_buff *skb,
255295
struct netlink_callback *cb)

net/smc/smc_ism.h

Lines changed: 4 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -48,6 +48,10 @@ int smc_ism_put_vlan(struct smcd_dev *dev, unsigned short vlan_id);
4848
int smc_ism_register_dmb(struct smc_link_group *lgr, int buf_size,
4949
struct smc_buf_desc *dmb_desc);
5050
int smc_ism_unregister_dmb(struct smcd_dev *dev, struct smc_buf_desc *dmb_desc);
51+
bool smc_ism_support_dmb_nocopy(struct smcd_dev *smcd);
52+
int smc_ism_attach_dmb(struct smcd_dev *dev, u64 token,
53+
struct smc_buf_desc *dmb_desc);
54+
int smc_ism_detach_dmb(struct smcd_dev *dev, u64 token);
5155
int smc_ism_signal_shutdown(struct smc_link_group *lgr);
5256
void smc_ism_get_system_eid(u8 **eid);
5357
u16 smc_ism_get_chid(struct smcd_dev *dev);

0 commit comments

Comments
 (0)