Commit 2a0fe4fe authored by Thierry Escande's avatar Thierry Escande Committed by Samuel Ortiz

NFC: nfcsim: Simulate lost frames through debugfs entry

This patch allows to simulate the lost of frames exchanged between the 2
nfcsim devices through a control entry in the debugfs and is used as
follow:

 echo n > /sys/kernel/debug/nfcsim/nfcX/dropframe

Where n specifies the number of frames to be dropped between 0 and 255
and nfcX is either nfc0 or nfc1, one of the two nfcsim devices.

In the following example, the next frame that should be sent by the nfc0
device will be dropped and thus not received by the nfc1 device:

 echo 1 > /sys/kernel/debug/nfcsim/nfc0/dropframe

The value of 0 can be used to reset the dropframe counter.
Signed-off-by: default avatarThierry Escande <thierry.escande@collabora.com>
Signed-off-by: default avatarSamuel Ortiz <sameo@linux.intel.com>
parent f9ac6273
...@@ -54,6 +54,8 @@ struct nfcsim { ...@@ -54,6 +54,8 @@ struct nfcsim {
nfc_digital_cmd_complete_t cb; nfc_digital_cmd_complete_t cb;
void *arg; void *arg;
u8 dropframe;
}; };
struct nfcsim_link { struct nfcsim_link {
...@@ -223,6 +225,14 @@ static int nfcsim_send(struct nfc_digital_dev *ddev, struct sk_buff *skb, ...@@ -223,6 +225,14 @@ static int nfcsim_send(struct nfc_digital_dev *ddev, struct sk_buff *skb,
schedule_work(&dev->recv_work); schedule_work(&dev->recv_work);
if (dev->dropframe) {
NFCSIM_DBG(dev, "dropping frame (out of %d)\n", dev->dropframe);
dev_kfree_skb(skb);
dev->dropframe--;
return 0;
}
if (skb) { if (skb) {
nfcsim_link_set_skb(dev->link_out, skb, dev->rf_tech, nfcsim_link_set_skb(dev->link_out, skb, dev->rf_tech,
dev->mode); dev->mode);
...@@ -372,6 +382,8 @@ static void nfcsim_debugfs_init_dev(struct nfcsim *dev) ...@@ -372,6 +382,8 @@ static void nfcsim_debugfs_init_dev(struct nfcsim *dev)
idx); idx);
return; return;
} }
debugfs_create_u8("dropframe", 0664, dev_dir, &dev->dropframe);
} }
static struct nfcsim *nfcsim_device_new(struct nfcsim_link *link_in, static struct nfcsim *nfcsim_device_new(struct nfcsim_link *link_in,
......
Markdown is supported
0%
or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment