* [PATCH net-next 0/5] mlx4: link sensing changes and Fixes.
From: Yevgeny Petrilin @ 2011-12-19 14:00 UTC (permalink / raw)
To: davem; +Cc: netdev, yevgenyp
Hello David,
This series presents link sensing logic changes (mostly for ConnectX3 devices)
and some fixes to the driver in addition to the SRIOV code we submitted lately.
Thanks,
Yevgeny
drivers/net/ethernet/mellanox/mlx4/cmd.c | 88 +++++++++++-------
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2
drivers/net/ethernet/mellanox/mlx4/fw.c | 2
drivers/net/ethernet/mellanox/mlx4/fw.h | 2
drivers/net/ethernet/mellanox/mlx4/main.c | 60 ++++++++----
drivers/net/ethernet/mellanox/mlx4/resource_tracker.c | 4
include/linux/mlx4/device.h | 5 -
7 files changed, 110 insertions(+), 53 deletions(-)
^ permalink raw reply
* [PATCH net-next 1/5] mlx4: capability for link sensing
From: Yevgeny Petrilin @ 2011-12-19 14:00 UTC (permalink / raw)
To: davem; +Cc: netdev, yevgenyp
From: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
For ConnectX3 devices, we allow link sensing only if FW explicitly
reported it supports the feature.
For older versions (ConnectX1 and 2), if the card supports both link layer types
(Ethenet and Infiniband), link sensing is supported.
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
---
drivers/net/ethernet/mellanox/mlx4/main.c | 10 ++++++++--
include/linux/mlx4/device.h | 3 ++-
2 files changed, 10 insertions(+), 3 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index b969bfb..8f73143 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -274,6 +274,10 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
dev->caps.stat_rate_support = dev_cap->stat_rate_support;
dev->caps.max_gso_sz = dev_cap->max_gso_sz;
+ /* Sense port always allowed on supported devices for ConnectX1 and 2 */
+ if (dev->pdev->device != 0x1003)
+ dev->caps.flags |= MLX4_DEV_CAP_FLAG_SENSE_SUPPORT;
+
dev->caps.log_num_macs = log_num_mac;
dev->caps.log_num_vlans = MLX4_LOG_NUM_VLANS;
dev->caps.log_num_prios = use_prio ? 3 : 0;
@@ -311,7 +315,8 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
}
dev->caps.possible_type[i] = dev->caps.port_type[i];
mlx4_priv(dev)->sense.sense_allowed[i] =
- dev->caps.supported_type[i] == MLX4_PORT_TYPE_AUTO;
+ ((dev->caps.supported_type[i] == MLX4_PORT_TYPE_AUTO) &&
+ (dev->caps.flags & MLX4_DEV_CAP_FLAG_SENSE_SUPPORT));
if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) {
dev->caps.log_num_macs = dev_cap->log_max_macs[i];
@@ -583,7 +588,8 @@ static ssize_t set_port_type(struct device *dev,
types[i] = mdev->caps.port_type[i+1];
}
- if (!(mdev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP)) {
+ if (!(mdev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP) &&
+ !(mdev->caps.flags & MLX4_DEV_CAP_FLAG_SENSE_SUPPORT)) {
for (i = 1; i <= mdev->caps.num_ports; i++) {
if (mdev->caps.possible_type[i] == MLX4_PORT_TYPE_AUTO) {
mdev->caps.possible_type[i] = mdev->caps.port_type[i];
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index 5f784ff..b06a44b 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -94,7 +94,8 @@ enum {
MLX4_DEV_CAP_FLAG_UDP_RSS = 1LL << 40,
MLX4_DEV_CAP_FLAG_VEP_UC_STEER = 1LL << 41,
MLX4_DEV_CAP_FLAG_VEP_MC_STEER = 1LL << 42,
- MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48
+ MLX4_DEV_CAP_FLAG_COUNTERS = 1LL << 48,
+ MLX4_DEV_CAP_FLAG_SENSE_SUPPORT = 1LL << 55
};
#define MLX4_ATTR_EXTENDED_PORT_INFO cpu_to_be16(0xff90)
--
1.7.7
^ permalink raw reply related
* [PATCH net-next 2/5] mlx4_core: Changing link sensing logic
From: Yevgeny Petrilin @ 2011-12-19 14:00 UTC (permalink / raw)
To: davem; +Cc: netdev, yevgenyp
From: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
New FW can give clues to driver regarding default port type
and whether or not we should default to link sensing on the port.
2 bits are added to QUERY_PORT command:
1. suggested_type: This bit gives a hint whether the default port type should be
IB or Ethernet.
The driver will use this hint in case the user didn't specify explicitly the link layer
type he wants to set.
2. default_sense: If this bit is set, we would sense the port type on start-up
and default the port to link sensing
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
---
drivers/net/ethernet/mellanox/mlx4/fw.c | 2 +
drivers/net/ethernet/mellanox/mlx4/fw.h | 2 +
drivers/net/ethernet/mellanox/mlx4/main.c | 50 +++++++++++++++++++---------
include/linux/mlx4/device.h | 2 +
4 files changed, 40 insertions(+), 16 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.c b/drivers/net/ethernet/mellanox/mlx4/fw.c
index f03b54e..abefcc8 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.c
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.c
@@ -577,6 +577,8 @@ int mlx4_QUERY_DEV_CAP(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
MLX4_GET(field, outbox, QUERY_PORT_SUPPORTED_TYPE_OFFSET);
dev_cap->supported_port_types[i] = field & 3;
+ dev_cap->suggested_type[i] = (field >> 3) & 1;
+ dev_cap->default_sense[i] = (field >> 4) & 1;
MLX4_GET(field, outbox, QUERY_PORT_MTU_OFFSET);
dev_cap->ib_mtu[i] = field & 0xf;
MLX4_GET(field, outbox, QUERY_PORT_WIDTH_OFFSET);
diff --git a/drivers/net/ethernet/mellanox/mlx4/fw.h b/drivers/net/ethernet/mellanox/mlx4/fw.h
index 3368363..119e0cc 100644
--- a/drivers/net/ethernet/mellanox/mlx4/fw.h
+++ b/drivers/net/ethernet/mellanox/mlx4/fw.h
@@ -111,6 +111,8 @@ struct mlx4_dev_cap {
u64 max_icm_sz;
int max_gso_sz;
u8 supported_port_types[MLX4_MAX_PORTS + 1];
+ u8 suggested_type[MLX4_MAX_PORTS + 1];
+ u8 default_sense[MLX4_MAX_PORTS + 1];
u8 log_max_macs[MLX4_MAX_PORTS + 1];
u8 log_max_vlans[MLX4_MAX_PORTS + 1];
u32 max_counters;
diff --git a/drivers/net/ethernet/mellanox/mlx4/main.c b/drivers/net/ethernet/mellanox/mlx4/main.c
index 8f73143..e984ded 100644
--- a/drivers/net/ethernet/mellanox/mlx4/main.c
+++ b/drivers/net/ethernet/mellanox/mlx4/main.c
@@ -130,10 +130,11 @@ int log_mtts_per_seg = ilog2(MLX4_MTT_ENTRY_PER_SEG);
module_param_named(log_mtts_per_seg, log_mtts_per_seg, int, 0444);
MODULE_PARM_DESC(log_mtts_per_seg, "Log2 number of MTT entries per segment (1-7)");
-static int port_type_array[2] = {1, 1};
+static int port_type_array[2] = {MLX4_PORT_TYPE_NONE, MLX4_PORT_TYPE_NONE};
static int arr_argc = 2;
module_param_array(port_type_array, int, &arr_argc, 0444);
-MODULE_PARM_DESC(port_type_array, "Array of port types: IB by default");
+MODULE_PARM_DESC(port_type_array, "Array of port types: HW_DEFAULT (0) is default "
+ "1 for IB, 2 for Ethernet");
struct mlx4_port_config {
struct list_head list;
@@ -225,6 +226,8 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
dev->caps.eth_mtu_cap[i] = dev_cap->eth_mtu[i];
dev->caps.def_mac[i] = dev_cap->def_mac[i];
dev->caps.supported_type[i] = dev_cap->supported_port_types[i];
+ dev->caps.suggested_type[i] = dev_cap->suggested_type[i];
+ dev->caps.default_sense[i] = dev_cap->default_sense[i];
dev->caps.trans_type[i] = dev_cap->trans_type[i];
dev->caps.vendor_oui[i] = dev_cap->vendor_oui[i];
dev->caps.wavelength[i] = dev_cap->wavelength[i];
@@ -302,22 +305,43 @@ static int mlx4_dev_cap(struct mlx4_dev *dev, struct mlx4_dev_cap *dev_cap)
* first of all check if SRIOV is on */
} else if (dev->flags & MLX4_FLAG_SRIOV)
dev->caps.port_type[i] = MLX4_PORT_TYPE_ETH;
- /* if IB and ETH are supported and SRIOV is off
- * use module parameters */
else {
- if (port_type_array[i-1])
- dev->caps.port_type[i] =
- MLX4_PORT_TYPE_IB;
+ /* In non-SRIOV mode, we set the port type
+ * according to user selection of port type,
+ * if usere selected none, take the FW hint */
+ if (port_type_array[i-1] == MLX4_PORT_TYPE_NONE)
+ dev->caps.port_type[i] = dev->caps.suggested_type[i] ?
+ MLX4_PORT_TYPE_ETH : MLX4_PORT_TYPE_IB;
else
- dev->caps.port_type[i] =
- MLX4_PORT_TYPE_ETH;
+ dev->caps.port_type[i] = port_type_array[i-1];
}
}
- dev->caps.possible_type[i] = dev->caps.port_type[i];
+ /*
+ * Link sensing is allowed on the port if 3 conditions are true:
+ * 1. Both protocols are supported on the port.
+ * 2. Different types are supported on the port
+ * 3. FW declared that it supports link sensing
+ */
mlx4_priv(dev)->sense.sense_allowed[i] =
((dev->caps.supported_type[i] == MLX4_PORT_TYPE_AUTO) &&
+ (dev->caps.flags & MLX4_DEV_CAP_FLAG_DPDP) &&
(dev->caps.flags & MLX4_DEV_CAP_FLAG_SENSE_SUPPORT));
+ /*
+ * If "default_sense" bit is set, we move the port to "AUTO" mode
+ * and perform sense_port FW command to try and set the correct
+ * port type from beginning
+ */
+ if (mlx4_priv(dev)->sense.sense_allowed && dev->caps.default_sense[i]) {
+ enum mlx4_port_type sensed_port = MLX4_PORT_TYPE_NONE;
+ dev->caps.possible_type[i] = MLX4_PORT_TYPE_AUTO;
+ mlx4_SENSE_PORT(dev, i, &sensed_port);
+ if (sensed_port != MLX4_PORT_TYPE_NONE)
+ dev->caps.port_type[i] = sensed_port;
+ } else {
+ dev->caps.possible_type[i] = dev->caps.port_type[i];
+ }
+
if (dev->caps.log_num_macs > dev_cap->log_max_macs[i]) {
dev->caps.log_num_macs = dev_cap->log_max_macs[i];
mlx4_warn(dev, "Requested number of MACs is too much "
@@ -1329,12 +1353,6 @@ static int mlx4_setup_hca(struct mlx4_dev *dev)
if (!mlx4_is_slave(dev)) {
for (port = 1; port <= dev->caps.num_ports; port++) {
- if (!mlx4_is_mfunc(dev)) {
- enum mlx4_port_type port_type = 0;
- mlx4_SENSE_PORT(dev, port, &port_type);
- if (port_type)
- dev->caps.port_type[port] = port_type;
- }
ib_port_default_caps = 0;
err = mlx4_get_port_ib_caps(dev, port,
&ib_port_default_caps);
diff --git a/include/linux/mlx4/device.h b/include/linux/mlx4/device.h
index b06a44b..5c4fe8e 100644
--- a/include/linux/mlx4/device.h
+++ b/include/linux/mlx4/device.h
@@ -303,6 +303,8 @@ struct mlx4_caps {
int log_num_prios;
enum mlx4_port_type port_type[MLX4_MAX_PORTS + 1];
u8 supported_type[MLX4_MAX_PORTS + 1];
+ u8 suggested_type[MLX4_MAX_PORTS + 1];
+ u8 default_sense[MLX4_MAX_PORTS + 1];
u32 port_mask[MLX4_MAX_PORTS + 1];
enum mlx4_port_type possible_type[MLX4_MAX_PORTS + 1];
u32 max_counters;
--
1.7.7
^ permalink raw reply related
* [PATCH net-next 3/5] mlx4_en: nullify cached multicast address list after cleanup
From: Yevgeny Petrilin @ 2011-12-19 14:02 UTC (permalink / raw)
To: davem; +Cc: netdev, yevgenyp
From: Alexander Guller <alexg@mellanox.com>
Solves an issue where we tried to free the same page twice after
the port has been opened and closed.
Signed-off-by: Alexander Guller <alexg@mellanox.com>
---
drivers/net/ethernet/mellanox/mlx4/en_netdev.c | 2 ++
1 files changed, 2 insertions(+), 0 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
index 1db6fea..72fa807 100644
--- a/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
+++ b/drivers/net/ethernet/mellanox/mlx4/en_netdev.c
@@ -151,6 +151,7 @@ static void mlx4_en_clear_list(struct net_device *dev)
struct mlx4_en_priv *priv = netdev_priv(dev);
kfree(priv->mc_addrs);
+ priv->mc_addrs = NULL;
priv->mc_addrs_cnt = 0;
}
@@ -170,6 +171,7 @@ static void mlx4_en_cache_mclist(struct net_device *dev)
i = 0;
netdev_for_each_mc_addr(ha, dev)
memcpy(mc_addrs + i++ * ETH_ALEN, ha->addr, ETH_ALEN);
+ mlx4_en_clear_list(dev);
priv->mc_addrs = mc_addrs;
priv->mc_addrs_cnt = mc_addrs_cnt;
}
--
1.7.7
^ permalink raw reply related
* [PATCH net-next 4/5] mlx4: not using spin_lock_irq when getting vf by resource.
From: Yevgeny Petrilin @ 2011-12-19 14:03 UTC (permalink / raw)
To: davem; +Cc: netdev, yevgenyp
From: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
The function is always called from irq context, changing the call
to spin_lock().
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
---
.../net/ethernet/mellanox/mlx4/resource_tracker.c | 4 ++--
1 files changed, 2 insertions(+), 2 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
index bdd61c3..b41762d 100644
--- a/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
+++ b/drivers/net/ethernet/mellanox/mlx4/resource_tracker.c
@@ -339,14 +339,14 @@ int mlx4_get_slave_from_resource_id(struct mlx4_dev *dev,
if (type == RES_QP)
id &= 0x7fffff;
- spin_lock_irq(mlx4_tlock(dev));
+ spin_lock(mlx4_tlock(dev));
r = find_res(dev, id, type);
if (r) {
*slave = r->owner;
err = 0;
}
- spin_unlock_irq(mlx4_tlock(dev));
+ spin_unlock(mlx4_tlock(dev));
return err;
}
--
1.7.7
^ permalink raw reply related
* [PATCH net-next 5/5] mlx4: Fixing wrong error codes in communication channel
From: Yevgeny Petrilin @ 2011-12-19 14:03 UTC (permalink / raw)
To: davem; +Cc: netdev, yevgenyp
From: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
The communication channel is HW interface from PF point of view
So the command return status should be stored as HW error code
and only then translated to errno values.
Reporetd-by: Dan Carpenter <dan.carpenter@oracle.com>
Signed-off-by: Yevgeny Petrilin <yevgenyp@mellanox.co.il>
---
drivers/net/ethernet/mellanox/mlx4/cmd.c | 88 +++++++++++++++++++-----------
1 files changed, 56 insertions(+), 32 deletions(-)
diff --git a/drivers/net/ethernet/mellanox/mlx4/cmd.c b/drivers/net/ethernet/mellanox/mlx4/cmd.c
index c4fef83..978f593 100644
--- a/drivers/net/ethernet/mellanox/mlx4/cmd.c
+++ b/drivers/net/ethernet/mellanox/mlx4/cmd.c
@@ -152,6 +152,26 @@ static int mlx4_status_to_errno(u8 status)
return trans_table[status];
}
+static u8 mlx4_errno_to_status(int errno)
+{
+ switch (errno) {
+ case -EPERM:
+ return CMD_STAT_BAD_OP;
+ case -EINVAL:
+ return CMD_STAT_BAD_PARAM;
+ case -ENXIO:
+ return CMD_STAT_BAD_SYS_STATE;
+ case -EBUSY:
+ return CMD_STAT_RESOURCE_BUSY;
+ case -ENOMEM:
+ return CMD_STAT_EXCEED_LIM;
+ case -ENFILE:
+ return CMD_STAT_ICM_ERROR;
+ default:
+ return CMD_STAT_INTERNAL_ERR;
+ }
+}
+
static int comm_pending(struct mlx4_dev *dev)
{
struct mlx4_priv *priv = mlx4_priv(dev);
@@ -361,10 +381,10 @@ static int mlx4_slave_cmd(struct mlx4_dev *dev, u64 in_param, u64 *out_param,
mlx4_err(dev, "response expected while"
"output mailbox is NULL for "
"command 0x%x\n", op);
- vhcr->status = -EINVAL;
+ vhcr->status = CMD_STAT_BAD_PARAM;
}
}
- ret = vhcr->status;
+ ret = mlx4_status_to_errno(vhcr->status);
}
} else {
ret = mlx4_comm_cmd(dev, MLX4_COMM_CMD_VHCR_POST, 0,
@@ -378,10 +398,10 @@ static int mlx4_slave_cmd(struct mlx4_dev *dev, u64 in_param, u64 *out_param,
mlx4_err(dev, "response expected while"
"output mailbox is NULL for "
"command 0x%x\n", op);
- vhcr->status = -EINVAL;
+ vhcr->status = CMD_STAT_BAD_PARAM;
}
}
- ret = vhcr->status;
+ ret = mlx4_status_to_errno(vhcr->status);
} else
mlx4_err(dev, "failed execution of VHCR_POST command"
"opcode 0x%x\n", op);
@@ -1066,6 +1086,7 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
u64 out_param;
int ret = 0;
int i;
+ int err = 0;
/* Create sw representation of Virtual HCR */
vhcr = kzalloc(sizeof(struct mlx4_vhcr), GFP_KERNEL);
@@ -1105,7 +1126,7 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
if (!cmd) {
mlx4_err(dev, "Unknown command:0x%x accepted from slave:%d\n",
vhcr->op, slave);
- vhcr_cmd->status = -EINVAL;
+ vhcr_cmd->status = CMD_STAT_BAD_PARAM;
goto out_status;
}
@@ -1114,18 +1135,18 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
vhcr->in_param &= INBOX_MASK;
inbox = mlx4_alloc_cmd_mailbox(dev);
if (IS_ERR(inbox)) {
- ret = PTR_ERR(inbox);
+ vhcr_cmd->status = CMD_STAT_BAD_SIZE;
inbox = NULL;
- goto out;
+ goto out_status;
}
- ret = mlx4_ACCESS_MEM(dev, inbox->dma, slave,
- vhcr->in_param,
- MLX4_MAILBOX_SIZE, 1);
- if (ret) {
+ if (mlx4_ACCESS_MEM(dev, inbox->dma, slave,
+ vhcr->in_param,
+ MLX4_MAILBOX_SIZE, 1)) {
mlx4_err(dev, "%s: Failed reading inbox (cmd:0x%x)\n",
__func__, cmd->opcode);
- goto out;
+ vhcr_cmd->status = CMD_STAT_INTERNAL_ERR;
+ goto out_status;
}
}
@@ -1134,7 +1155,7 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
mlx4_warn(dev, "Command:0x%x from slave: %d failed protection "
"checks for resource_id:%d\n", vhcr->op, slave,
vhcr->in_modifier);
- vhcr_cmd->status = -EPERM;
+ vhcr_cmd->status = CMD_STAT_BAD_OP;
goto out_status;
}
@@ -1142,16 +1163,16 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
if (cmd->has_outbox) {
outbox = mlx4_alloc_cmd_mailbox(dev);
if (IS_ERR(outbox)) {
- ret = PTR_ERR(outbox);
+ vhcr_cmd->status = CMD_STAT_BAD_SIZE;
outbox = NULL;
- goto out;
+ goto out_status;
}
}
/* Execute the command! */
if (cmd->wrapper) {
- vhcr_cmd->status = cmd->wrapper(dev, slave, vhcr, inbox, outbox,
- cmd);
+ err = cmd->wrapper(dev, slave, vhcr, inbox, outbox,
+ cmd);
if (cmd->out_is_imm)
vhcr_cmd->out_param = cpu_to_be64(vhcr->out_param);
} else {
@@ -1159,20 +1180,11 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
vhcr->in_param;
out_param = cmd->has_outbox ? (u64) outbox->dma :
vhcr->out_param;
- vhcr_cmd->status = __mlx4_cmd(dev, in_param, &out_param,
- cmd->out_is_imm, vhcr->in_modifier,
- vhcr->op_modifier, vhcr->op,
- MLX4_CMD_TIME_CLASS_A,
- MLX4_CMD_NATIVE);
-
- if (vhcr_cmd->status) {
- mlx4_warn(dev, "vhcr command:0x%x slave:%d failed with"
- " error:%d, status %d\n",
- vhcr->op, slave, vhcr->errno,
- vhcr_cmd->status);
- ret = vhcr_cmd->status;
- goto out;
- }
+ err = __mlx4_cmd(dev, in_param, &out_param,
+ cmd->out_is_imm, vhcr->in_modifier,
+ vhcr->op_modifier, vhcr->op,
+ MLX4_CMD_TIME_CLASS_A,
+ MLX4_CMD_NATIVE);
if (cmd->out_is_imm) {
vhcr->out_param = out_param;
@@ -1180,12 +1192,24 @@ static int mlx4_master_process_vhcr(struct mlx4_dev *dev, int slave,
}
}
+ if (err) {
+ mlx4_warn(dev, "vhcr command:0x%x slave:%d failed with"
+ " error:%d, status %d\n",
+ vhcr->op, slave, vhcr->errno, err);
+ vhcr_cmd->status = mlx4_errno_to_status(err);
+ goto out_status;
+ }
+
+
/* Write outbox if command completed successfully */
- if (cmd->has_outbox && !vhcr->errno) {
+ if (cmd->has_outbox && !vhcr_cmd->status) {
ret = mlx4_ACCESS_MEM(dev, outbox->dma, slave,
vhcr->out_param,
MLX4_MAILBOX_SIZE, MLX4_CMD_WRAPPED);
if (ret) {
+ /* If we failed to write back the outbox after the
+ *command was successfully executed, we must fail this
+ * slave, as it is now in undefined state */
mlx4_err(dev, "%s:Failed writing outbox\n", __func__);
goto out;
}
--
1.7.7
^ permalink raw reply related
* [PATCH 05/14] mac802154: define reduced mlme operations
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
According IEEE 802.15.4 standard each node can be either full functionality
device (FFD) or reduce functionality device (RFD). So 2 sets of operations
are needed. This patch define RFD operations structure.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/net/ieee802154_netdev.h | 20 ++++++++++++++++++--
1 files changed, 18 insertions(+), 2 deletions(-)
diff --git a/include/net/ieee802154_netdev.h b/include/net/ieee802154_netdev.h
index 12a7ee4..f74c5db 100644
--- a/include/net/ieee802154_netdev.h
+++ b/include/net/ieee802154_netdev.h
@@ -83,6 +83,14 @@ struct wpan_phy;
* get_phy should increment the reference counting on returned phy.
* Use wpan_wpy_put to put that reference.
*/
+
+/*
+ * The IEEE 802.15.4 standard defines 2 type of devices:
+ * - FFD - full functionality device
+ * - RFD - reduce functionality device
+ *
+ * So 2 sets of mlme operations are needed
+ */
struct ieee802154_mlme_ops {
int (*assoc_req)(struct net_device *dev,
struct ieee802154_addr *addr,
@@ -112,12 +120,20 @@ struct ieee802154_mlme_ops {
u8 (*get_bsn)(const struct net_device *dev);
};
+struct ieee802154_reduced_mlme_ops {
+ struct wpan_phy *(*get_phy)(const struct net_device *dev);
+};
+
static inline struct ieee802154_mlme_ops *ieee802154_mlme_ops(
const struct net_device *dev)
{
return dev->ml_priv;
}
-#endif
-
+static inline struct ieee802154_reduced_mlme_ops *ieee802154_reduced_mlme_ops(
+ const struct net_device *dev)
+{
+ return dev->ml_priv;
+}
+#endif
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 06/14] mac802154: slave interfaces definition
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
Slaves represent typical network interfaces available from userspace.
Each ieee802154 device/transceiver may have several slaves and able
to be associated with several networks at the same time.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
net/mac802154/mac802154.h | 25 +++++++++++++++++++++++++
1 files changed, 25 insertions(+), 0 deletions(-)
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index 97f9155..cef6a4f 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -56,6 +56,31 @@ enum {
MAC802154_DEVICE_RUN,
};
+/*
+ * Slave interface definition
+ */
+struct mac802154_sub_if_data {
+ struct list_head list; /* the ieee802154_priv->slaves list */
+
+ struct mac802154_priv *hw;
+ struct net_device *dev;
+
+ int type;
+
+ spinlock_t mib_lock;
+
+ u16 pan_id;
+ u16 short_addr;
+
+ u8 chan;
+ u8 page;
+
+ /* MAC BSN field */
+ u8 bsn;
+ /* MAC DSN field */
+ u8 dsn;
+};
+
#define mac802154_to_priv(_hw) container_of(_hw, struct mac802154_priv, hw)
#define MAC802154_MAX_XMIT_ATTEMPTS 3
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 07/14] mac802154: reduced mlme operations
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
Initialize set of reduced operations.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
net/mac802154/Makefile | 2 +-
net/mac802154/mac802154.h | 2 ++
net/mac802154/mac_cmd.c | 43 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 46 insertions(+), 1 deletions(-)
create mode 100644 net/mac802154/mac_cmd.c
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 490beef..4d9dd0f 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -1,2 +1,2 @@
obj-$(CONFIG_MAC802154) += mac802154.o
-mac802154-objs := ieee802154_dev.o rx.o tx.o
+mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index cef6a4f..fc0aa75 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -85,6 +85,8 @@ struct mac802154_sub_if_data {
#define MAC802154_MAX_XMIT_ATTEMPTS 3
+extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
+
netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
u8 page, u8 chan);
diff --git a/net/mac802154/mac_cmd.c b/net/mac802154/mac_cmd.c
new file mode 100644
index 0000000..941c3e4
--- /dev/null
+++ b/net/mac802154/mac_cmd.c
@@ -0,0 +1,43 @@
+/*
+ * MAC commands interface
+ *
+ * Copyright 2007-2011 Siemens AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by:
+ * Sergey Lapin <slapin-9cOl001CZnBAfugRpC6u6w@public.gmane.org>
+ * Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ */
+
+#include <linux/skbuff.h>
+#include <linux/if_arp.h>
+#include <net/ieee802154_netdev.h>
+#include <net/wpan-phy.h>
+#include <net/mac802154.h>
+
+#include "mac802154.h"
+
+struct wpan_phy *mac802154_get_phy(const struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+ BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+ return to_phy(get_device(&priv->hw->phy->dev));
+}
+
+struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced = {
+ .get_phy = mac802154_get_phy,
+};
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 08/14] mac802154: basic mib support
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
Basic support for IEEE 802.15.4 management information base.
Currently setting of HW address is implemented only.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
net/mac802154/Makefile | 2 +-
net/mac802154/mac802154.h | 3 +
net/mac802154/mib.c | 96 +++++++++++++++++++++++++++++++++++++++++++++
3 files changed, 100 insertions(+), 1 deletions(-)
create mode 100644 net/mac802154/mib.c
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 4d9dd0f..6b348b0 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -1,2 +1,2 @@
obj-$(CONFIG_MAC802154) += mac802154.o
-mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o
+mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index fc0aa75..d0e3d8d 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -90,4 +90,7 @@ extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
u8 page, u8 chan);
+/* MIB callbacks */
+void mac802154_dev_set_ieee_addr(struct net_device *dev);
+
#endif /* MAC802154_H */
diff --git a/net/mac802154/mib.c b/net/mac802154/mib.c
new file mode 100644
index 0000000..1a3c913
--- /dev/null
+++ b/net/mac802154/mib.c
@@ -0,0 +1,96 @@
+/*
+ * Copyright 2007, 2008, 2009 Siemens AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by:
+ * Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ * Sergey Lapin <slapin-9cOl001CZnBAfugRpC6u6w@public.gmane.org>
+ * Maxim Gorbachyov <maxim.gorbachev-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
+ */
+
+#include <linux/if_arp.h>
+
+#include <net/mac802154.h>
+#include <net/wpan-phy.h>
+
+#include "mac802154.h"
+
+struct phy_chan_notify_work {
+ struct work_struct work;
+ struct net_device *dev;
+};
+
+struct hw_addr_filt_notify_work {
+ struct work_struct work;
+ struct net_device *dev;
+ unsigned long changed;
+};
+
+struct mac802154_priv *mac802154_slave_get_priv(struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+ BUG_ON(dev->type != ARPHRD_IEEE802154);
+
+ return priv->hw;
+}
+
+static void hw_addr_notify(struct work_struct *work)
+{
+ struct hw_addr_filt_notify_work *nw = container_of(work,
+ struct hw_addr_filt_notify_work, work);
+ struct mac802154_priv *hw = mac802154_slave_get_priv(nw->dev);
+ int res;
+
+ res = hw->ops->set_hw_addr_filt(&hw->hw,
+ &hw->hw.hw_filt, nw->changed);
+ if (res)
+ pr_debug("%s: failed changed mask %lx\n",
+ __func__, nw->changed);
+
+ kfree(nw);
+
+ return;
+}
+
+static void set_hw_addr_filt(struct net_device *dev, unsigned long changed)
+{
+ struct mac802154_sub_if_data *priv = netdev_priv(dev);
+ struct hw_addr_filt_notify_work *work;
+
+ work = kzalloc(sizeof(*work), GFP_ATOMIC);
+ if (!work)
+ return;
+
+ INIT_WORK(&work->work, hw_addr_notify);
+ work->dev = dev;
+ work->changed = changed;
+ queue_work(priv->hw->dev_workqueue, &work->work);
+
+ return;
+}
+
+void mac802154_dev_set_ieee_addr(struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+ if (priv->hw->ops->set_hw_addr_filt &&
+ memcmp(priv->hw->hw.hw_filt.ieee_addr,
+ dev->dev_addr, IEEE802154_ADDR_LEN)) {
+ memcpy(priv->hw->hw.hw_filt.ieee_addr,
+ dev->dev_addr, IEEE802154_ADDR_LEN);
+ set_hw_addr_filt(dev, IEEE802515_IEEEADDR_CHANGED);
+ }
+}
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 09/14] ieee802154: remove ieee802154 policy from globals
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA,
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
Move ieee802154 netlink policy array definition inside ieee802154 layer.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/linux/nl802154.h | 2 --
net/ieee802154/ieee802154.h | 2 ++
net/ieee802154/wpan-class.c | 1 +
3 files changed, 3 insertions(+), 2 deletions(-)
diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index 33d9f51..d2b5ae2 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -74,8 +74,6 @@ enum {
#define IEEE802154_ATTR_MAX (__IEEE802154_ATTR_MAX - 1)
-extern const struct nla_policy ieee802154_policy[];
-
/* commands */
/* REQ should be responded with CONF
* and INDIC with RESP
diff --git a/net/ieee802154/ieee802154.h b/net/ieee802154/ieee802154.h
index aadec42..e9799af 100644
--- a/net/ieee802154/ieee802154.h
+++ b/net/ieee802154/ieee802154.h
@@ -21,6 +21,8 @@
int __init ieee802154_nl_init(void);
void __exit ieee802154_nl_exit(void);
+extern const struct nla_policy ieee802154_policy[];
+
#define IEEE802154_OP(_cmd, _func) \
{ \
.cmd = _cmd, \
diff --git a/net/ieee802154/wpan-class.c b/net/ieee802154/wpan-class.c
index 1627ef2..36d32e2 100644
--- a/net/ieee802154/wpan-class.c
+++ b/net/ieee802154/wpan-class.c
@@ -21,6 +21,7 @@
#include <linux/module.h>
#include <linux/device.h>
+#include <net/netlink.h>
#include <net/wpan-phy.h>
#include "ieee802154.h"
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 10/14] ieee802154: interface type to be added
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Alexander Smirnov (none),
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
From: Alexander Smirnov <alexander@Lenovo.(none)>
This stack supports several types of slaves interfaces. Another
parameter to 'add_iface_ function added.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/linux/nl802154.h | 5 +++++
include/net/wpan-phy.h | 2 +-
net/ieee802154/nl-phy.c | 10 +++++++++-
3 files changed, 15 insertions(+), 2 deletions(-)
diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index d2b5ae2..8fa29ff 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -68,6 +68,7 @@ enum {
IEEE802154_ATTR_CHANNEL_PAGE_LIST,
IEEE802154_ATTR_PHY_NAME,
+ IEEE802154_ATTR_DEV_TYPE,
__IEEE802154_ATTR_MAX,
};
@@ -124,4 +125,8 @@ enum {
#define IEEE802154_CMD_MAX (__IEEE802154_CMD_MAX - 1)
+enum {
+ __IEEE802154_DEV_MAX,
+};
+
#endif
diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h
index d86fffd..0c2c931 100644
--- a/include/net/wpan-phy.h
+++ b/include/net/wpan-phy.h
@@ -42,7 +42,7 @@ struct wpan_phy {
int idx;
struct net_device *(*add_iface)(struct wpan_phy *phy,
- const char *name);
+ const char *name, int type);
void (*del_iface)(struct wpan_phy *phy, struct net_device *dev);
char priv[0] __attribute__((__aligned__(NETDEV_ALIGN)));
diff --git a/net/ieee802154/nl-phy.c b/net/ieee802154/nl-phy.c
index c64a38d..cf3cd71 100644
--- a/net/ieee802154/nl-phy.c
+++ b/net/ieee802154/nl-phy.c
@@ -179,6 +179,7 @@ static int ieee802154_add_iface(struct sk_buff *skb,
const char *devname;
int rc = -ENOBUFS;
struct net_device *dev;
+ int type = -EINVAL;
pr_debug("%s\n", __func__);
@@ -221,7 +222,14 @@ static int ieee802154_add_iface(struct sk_buff *skb,
goto nla_put_failure;
}
- dev = phy->add_iface(phy, devname);
+ if (info->attrs[IEEE802154_ATTR_DEV_TYPE]) {
+ type = nla_get_u8(info->attrs[IEEE802154_ATTR_DEV_TYPE]);
+ if (type > __IEEE802154_DEV_MAX) {
+ return -EINVAL;
+ }
+ }
+
+ dev = phy->add_iface(phy, devname, type);
if (IS_ERR(dev)) {
rc = PTR_ERR(dev);
goto nla_put_failure;
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 11/14] mac802154: slaves manipulation routine
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Alexander Smirnov (none),
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
From: Alexander Smirnov <alexander@Lenovo.(none)>
This patch adds interface for registration and removing slaves in the
system.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/net/mac802154.h | 4 +
net/mac802154/ieee802154_dev.c | 140 +++++++++++++++++++++++++++++++++++++++-
net/mac802154/mac802154.h | 3 +
3 files changed, 146 insertions(+), 1 deletions(-)
diff --git a/include/net/mac802154.h b/include/net/mac802154.h
index 4e9f042..4854885 100644
--- a/include/net/mac802154.h
+++ b/include/net/mac802154.h
@@ -139,6 +139,10 @@ struct ieee802154_ops {
u8 addr[IEEE802154_ADDR_LEN]);
};
+struct ieee802154_dev *ieee802154_alloc_device(size_t priv_size,
+ struct ieee802154_ops *ops);
+void ieee802154_free_device(struct ieee802154_dev *dev);
+
int ieee802154_register_device(struct ieee802154_dev *dev);
void ieee802154_unregister_device(struct ieee802154_dev *dev);
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index 2bd1034..649409c 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -18,13 +18,137 @@
#include <linux/kernel.h>
#include <linux/netdevice.h>
+#include <linux/nl802154.h>
#include <net/route.h>
-
#include <net/mac802154.h>
#include <net/wpan-phy.h>
#include "mac802154.h"
+int mac802154_slave_open(struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv = netdev_priv(dev);
+ int res = 0;
+
+ if (priv->hw->open_count++ == 0) {
+ res = priv->hw->ops->start(&priv->hw->hw);
+ WARN_ON(res);
+ if (res)
+ goto err;
+ }
+
+ if (priv->hw->ops->ieee_addr) {
+ res = priv->hw->ops->ieee_addr(&priv->hw->hw, dev->dev_addr);
+ WARN_ON(res);
+ if (res)
+ goto err;
+ mac802154_dev_set_ieee_addr(dev);
+ }
+
+ netif_start_queue(dev);
+ return 0;
+err:
+ priv->hw->open_count--;
+
+ return res;
+}
+
+int mac802154_slave_close(struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv = netdev_priv(dev);
+
+ netif_stop_queue(dev);
+
+ if ((--priv->hw->open_count) == 0)
+ priv->hw->ops->stop(&priv->hw->hw);
+
+ return 0;
+}
+
+static int mac802154_netdev_register(struct wpan_phy *phy,
+ struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv;
+ struct mac802154_priv *ipriv;
+ int err;
+
+ ipriv = wpan_phy_priv(phy);
+
+ priv = netdev_priv(dev);
+ priv->dev = dev;
+ priv->hw = ipriv;
+
+ dev->needed_headroom = ipriv->hw.extra_tx_headroom;
+
+ SET_NETDEV_DEV(dev, &ipriv->phy->dev);
+
+ mutex_lock(&ipriv->slaves_mtx);
+ if (!ipriv->running) {
+ mutex_unlock(&ipriv->slaves_mtx);
+ return -ENODEV;
+ }
+ mutex_unlock(&ipriv->slaves_mtx);
+
+ err = register_netdev(dev);
+ if (err < 0)
+ return err;
+
+ rtnl_lock();
+ mutex_lock(&ipriv->slaves_mtx);
+ list_add_tail_rcu(&priv->list, &ipriv->slaves);
+ mutex_unlock(&ipriv->slaves_mtx);
+ rtnl_unlock();
+
+ return 0;
+}
+
+static void mac802154_del_iface(struct wpan_phy *phy,
+ struct net_device *dev)
+{
+ struct mac802154_sub_if_data *sdata;
+ ASSERT_RTNL();
+
+ sdata = netdev_priv(dev);
+
+ BUG_ON(sdata->hw->phy != phy);
+
+ mutex_lock(&sdata->hw->slaves_mtx);
+ list_del_rcu(&sdata->list);
+ mutex_unlock(&sdata->hw->slaves_mtx);
+
+ synchronize_rcu();
+ unregister_netdevice(sdata->dev);
+}
+
+static struct net_device *mac802154_add_iface(struct wpan_phy *phy,
+ const char *name, int type)
+{
+ struct net_device *dev;
+ int err = -ENOMEM;
+
+ /* No devices is currently supported */
+ switch (type) {
+ default:
+ dev = NULL;
+ err = -EINVAL;
+ break;
+ }
+ if (!dev)
+ goto err;
+
+ err = mac802154_netdev_register(phy, dev);
+ if (err)
+ goto err_free;
+
+ dev_hold(dev); /* we return a device w/ incremented refcount */
+ return dev;
+
+err_free:
+ free_netdev(dev);
+err:
+ return ERR_PTR(err);
+}
+
struct ieee802154_dev *ieee802154_alloc_device(size_t priv_size,
struct ieee802154_ops *ops)
{
@@ -61,6 +185,8 @@ void ieee802154_free_device(struct ieee802154_dev *hw)
{
struct mac802154_priv *priv = mac802154_to_priv(hw);
+ BUG_ON(!list_empty(&priv->slaves));
+
wpan_phy_free(priv->phy);
mutex_destroy(&priv->slaves_mtx);
@@ -80,6 +206,9 @@ int ieee802154_register_device(struct ieee802154_dev *dev)
wpan_phy_set_dev(priv->phy, priv->hw.parent);
+ priv->phy->add_iface = mac802154_add_iface;
+ priv->phy->del_iface = mac802154_del_iface;
+
rc = wpan_phy_register(priv->phy);
if (rc < 0)
goto out_wq;
@@ -104,6 +233,7 @@ EXPORT_SYMBOL(ieee802154_register_device);
void ieee802154_unregister_device(struct ieee802154_dev *dev)
{
struct mac802154_priv *priv = mac802154_to_priv(dev);
+ struct mac802154_sub_if_data *sdata, *next;
flush_workqueue(priv->dev_workqueue);
destroy_workqueue(priv->dev_workqueue);
@@ -114,6 +244,14 @@ void ieee802154_unregister_device(struct ieee802154_dev *dev)
priv->running = MAC802154_DEVICE_STOPPED;
mutex_unlock(&priv->slaves_mtx);
+ list_for_each_entry_safe(sdata, next, &priv->slaves, list) {
+ mutex_lock(&sdata->hw->slaves_mtx);
+ list_del(&sdata->list);
+ mutex_unlock(&sdata->hw->slaves_mtx);
+
+ unregister_netdevice(sdata->dev);
+ }
+
rtnl_unlock();
wpan_phy_unregister(priv->phy);
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index d0e3d8d..f6f6f0a 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -87,6 +87,9 @@ struct mac802154_sub_if_data {
extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
+int mac802154_slave_open(struct net_device *dev);
+int mac802154_slave_close(struct net_device *dev);
+
netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
u8 page, u8 chan);
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 12/14] mac802154: monitor device support
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Alexander Smirnov (none),
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
From: Alexander Smirnov <alexander@Lenovo.(none)>
Support for monitor device intended to capture all the network
activity. This interface could be used by networks sniffers.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
include/linux/if_arp.h | 1 +
include/linux/nl802154.h | 1 +
include/net/wpan-phy.h | 2 +
net/mac802154/Makefile | 2 +-
net/mac802154/ieee802154_dev.c | 5 ++-
net/mac802154/mac802154.h | 3 +
net/mac802154/monitor.c | 115 ++++++++++++++++++++++++++++++++++++++++
net/mac802154/rx.c | 1 +
8 files changed, 128 insertions(+), 2 deletions(-)
create mode 100644 net/mac802154/monitor.c
diff --git a/include/linux/if_arp.h b/include/linux/if_arp.h
index 6d722f4..f0e69c6 100644
--- a/include/linux/if_arp.h
+++ b/include/linux/if_arp.h
@@ -87,6 +87,7 @@
#define ARPHRD_IEEE80211_PRISM 802 /* IEEE 802.11 + Prism2 header */
#define ARPHRD_IEEE80211_RADIOTAP 803 /* IEEE 802.11 + radiotap header */
#define ARPHRD_IEEE802154 804
+#define ARPHRD_IEEE802154_MONITOR 805 /* IEEE 802.15.4 network monitor */
#define ARPHRD_PHONET 820 /* PhoNet media type */
#define ARPHRD_PHONET_PIPE 821 /* PhoNet pipe header */
diff --git a/include/linux/nl802154.h b/include/linux/nl802154.h
index 8fa29ff..6152fc9 100644
--- a/include/linux/nl802154.h
+++ b/include/linux/nl802154.h
@@ -126,6 +126,7 @@ enum {
#define IEEE802154_CMD_MAX (__IEEE802154_CMD_MAX - 1)
enum {
+ IEEE802154_DEV_MONITOR = 1, /* for compatibility with WireShark */
__IEEE802154_DEV_MAX,
};
diff --git a/include/net/wpan-phy.h b/include/net/wpan-phy.h
index 0c2c931..368da0b 100644
--- a/include/net/wpan-phy.h
+++ b/include/net/wpan-phy.h
@@ -24,6 +24,8 @@
#include <linux/netdevice.h>
#include <linux/mutex.h>
+#define WPAN_NUM_PAGES 32
+
struct wpan_phy {
struct mutex pib_lock;
diff --git a/net/mac802154/Makefile b/net/mac802154/Makefile
index 6b348b0..ec1bd3f 100644
--- a/net/mac802154/Makefile
+++ b/net/mac802154/Makefile
@@ -1,2 +1,2 @@
obj-$(CONFIG_MAC802154) += mac802154.o
-mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o
+mac802154-objs := ieee802154_dev.o rx.o tx.o mac_cmd.o mib.o monitor.o
diff --git a/net/mac802154/ieee802154_dev.c b/net/mac802154/ieee802154_dev.c
index 649409c..03330d3 100644
--- a/net/mac802154/ieee802154_dev.c
+++ b/net/mac802154/ieee802154_dev.c
@@ -126,8 +126,11 @@ static struct net_device *mac802154_add_iface(struct wpan_phy *phy,
struct net_device *dev;
int err = -ENOMEM;
- /* No devices is currently supported */
switch (type) {
+ case IEEE802154_DEV_MONITOR:
+ dev = alloc_netdev(sizeof(struct mac802154_sub_if_data),
+ name, mac802154_monitor_setup);
+ break;
default:
dev = NULL;
err = -EINVAL;
diff --git a/net/mac802154/mac802154.h b/net/mac802154/mac802154.h
index f6f6f0a..2a301d0 100644
--- a/net/mac802154/mac802154.h
+++ b/net/mac802154/mac802154.h
@@ -90,6 +90,9 @@ extern struct ieee802154_reduced_mlme_ops mac802154_mlme_reduced;
int mac802154_slave_open(struct net_device *dev);
int mac802154_slave_close(struct net_device *dev);
+void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb);
+void mac802154_monitor_setup(struct net_device *dev);
+
netdev_tx_t mac802154_tx(struct mac802154_priv *priv, struct sk_buff *skb,
u8 page, u8 chan);
diff --git a/net/mac802154/monitor.c b/net/mac802154/monitor.c
new file mode 100644
index 0000000..ccc5e81
--- /dev/null
+++ b/net/mac802154/monitor.c
@@ -0,0 +1,115 @@
+/*
+ * Copyright 2007, 2008, 2009 Siemens AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by:
+ * Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ * Sergey Lapin <slapin-9cOl001CZnBAfugRpC6u6w@public.gmane.org>
+ * Maxim Gorbachyov <maxim.gorbachev-kv7WeFo6aLtBDgjK7y7TUQ@public.gmane.org>
+ */
+
+#include <linux/netdevice.h>
+#include <linux/skbuff.h>
+#include <linux/if_arp.h>
+#include <linux/crc-ccitt.h>
+#include <linux/nl802154.h>
+#include <net/ieee802154.h>
+#include <net/mac802154.h>
+#include <net/wpan-phy.h>
+
+#include "mac802154.h"
+
+static netdev_tx_t mac802154_monitor_xmit(struct sk_buff *skb, struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv;
+ u8 chan, page;
+
+ priv = netdev_priv(dev);
+
+ /* FIXME: locking */
+ chan = priv->hw->phy->current_channel;
+ page = priv->hw->phy->current_page;
+
+ if (chan == (u8)-1) /* not init */
+ return NETDEV_TX_OK;
+
+ BUG_ON(page >= WPAN_NUM_PAGES);
+ BUG_ON(chan >= 27);
+
+ skb->skb_iif = dev->ifindex;
+ dev->stats.tx_packets++;
+ dev->stats.tx_bytes += skb->len;
+
+ return mac802154_tx(priv->hw, skb, page, chan);
+}
+
+
+void mac802154_monitors_rx(struct mac802154_priv *priv, struct sk_buff *skb)
+{
+ struct sk_buff *skb2;
+ struct mac802154_sub_if_data *sdata;
+ u16 crc = crc_ccitt(0, skb->data, skb->len);
+ u8 *data;
+
+ rcu_read_lock();
+ list_for_each_entry_rcu(sdata, &priv->slaves, list) {
+ if (sdata->type != IEEE802154_DEV_MONITOR)
+ continue;
+
+ skb2 = skb_clone(skb, GFP_ATOMIC);
+ skb2->dev = sdata->dev;
+ skb2->pkt_type = PACKET_HOST;
+ data = skb_put(skb2, 2);
+ data[0] = crc & 0xff;
+ data[1] = crc >> 8;
+
+ if (in_interrupt())
+ netif_rx(skb2);
+ else
+ netif_rx_ni(skb2);
+ }
+ rcu_read_unlock();
+}
+
+static const struct net_device_ops mac802154_monitor_ops = {
+ .ndo_open = mac802154_slave_open,
+ .ndo_stop = mac802154_slave_close,
+ .ndo_start_xmit = mac802154_monitor_xmit,
+};
+
+void mac802154_monitor_setup(struct net_device *dev)
+{
+ struct mac802154_sub_if_data *priv;
+
+ dev->addr_len = 0;
+ dev->hard_header_len = 0;
+ dev->needed_tailroom = 2; /* FCS */
+ dev->mtu = IEEE802154_MTU;
+ dev->tx_queue_len = 10;
+ dev->type = ARPHRD_IEEE802154_MONITOR;
+ dev->flags = IFF_NOARP | IFF_BROADCAST;
+ dev->watchdog_timeo = 0;
+
+ dev->destructor = free_netdev;
+ dev->netdev_ops = &mac802154_monitor_ops;
+ dev->ml_priv = &mac802154_mlme_reduced;
+
+ priv = netdev_priv(dev);
+ priv->type = IEEE802154_DEV_MONITOR;
+
+ priv->chan = -1; /* not initialized */
+ priv->page = 0; /* for compat */
+}
+
diff --git a/net/mac802154/rx.c b/net/mac802154/rx.c
index d469bef..335efbf 100644
--- a/net/mac802154/rx.c
+++ b/net/mac802154/rx.c
@@ -60,6 +60,7 @@ mac802154_subif_rx(struct ieee802154_dev *hw, struct sk_buff *skb, u8 lqi)
skb_trim(skb, skb->len - 2); /* CRC */
}
+ mac802154_monitors_rx(priv, skb);
out:
dev_kfree_skb(skb);
return;
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* [PATCH 13/14] drivers/ieee802154: IEEE 802.15.4 loopback driver
From: Alexander Smirnov @ 2011-12-19 16:33 UTC (permalink / raw)
To: davem-fT/PcQaiUtIeIZ0/mPfg9Q
Cc: netdev-u79uwXL29TY76Z2rM5mHXA, Alexander Smirnov (none),
linux-zigbee-devel-5NWGOfrQmneRv+LV9MX5uipxlwaOVQ5f
In-Reply-To: <20111219163117.GA13123-AUGNqIMGY+bGcXpsla5Oef8+0UxHXcjY@public.gmane.org>
From: Alexander Smirnov <alexander@Lenovo.(none)>
Add support for loopback driver. It's very useful tool for testing
and development upper IEEE 802.15.4 layer.
Signed-off-by: Alexander Smirnov <alex.bluesman.smirnov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
---
drivers/ieee802154/Kconfig | 8 ++
drivers/ieee802154/Makefile | 1 +
drivers/ieee802154/fakelb.c | 287 +++++++++++++++++++++++++++++++++++++++++++
3 files changed, 296 insertions(+), 0 deletions(-)
create mode 100644 drivers/ieee802154/fakelb.c
diff --git a/drivers/ieee802154/Kconfig b/drivers/ieee802154/Kconfig
index 9b9f43a..15c0640 100644
--- a/drivers/ieee802154/Kconfig
+++ b/drivers/ieee802154/Kconfig
@@ -19,4 +19,12 @@ config IEEE802154_FAKEHARD
This driver can also be built as a module. To do so say M here.
The module will be called 'fakehard'.
+config IEEE802154_FAKELB
+ depends on IEEE802154_DRIVERS && MAC802154
+ tristate "IEEE 802.15.4 loopback driver"
+ ---help---
+ Say Y here to enable the fake driver that can emulate a net
+ of several interconnected radio devices.
+ This driver can also be built as a module. To do so say M here.
+ The module will be called 'fakelb'.
diff --git a/drivers/ieee802154/Makefile b/drivers/ieee802154/Makefile
index 800a389..ea784ea 100644
--- a/drivers/ieee802154/Makefile
+++ b/drivers/ieee802154/Makefile
@@ -1 +1,2 @@
obj-$(CONFIG_IEEE802154_FAKEHARD) += fakehard.o
+obj-$(CONFIG_IEEE802154_FAKELB) += fakelb.o
diff --git a/drivers/ieee802154/fakelb.c b/drivers/ieee802154/fakelb.c
new file mode 100644
index 0000000..35689e4
--- /dev/null
+++ b/drivers/ieee802154/fakelb.c
@@ -0,0 +1,287 @@
+/*
+ * Loopback IEEE 802.15.4 interface
+ *
+ * Copyright 2007-2011 Siemens AG
+ *
+ * This program is free software; you can redistribute it and/or modify
+ * it under the terms of the GNU General Public License version 2
+ * as published by the Free Software Foundation.
+ *
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+ *
+ * You should have received a copy of the GNU General Public License along
+ * with this program; if not, write to the Free Software Foundation, Inc.,
+ * 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA.
+ *
+ * Written by:
+ * Sergey Lapin <slapin-9cOl001CZnBAfugRpC6u6w@public.gmane.org>
+ * Dmitry Eremin-Solenikov <dbaryshkov-Re5JQEeQqe8AvxtiuMwx3w@public.gmane.org>
+ */
+
+#include <linux/module.h>
+#include <linux/timer.h>
+#include <linux/platform_device.h>
+#include <linux/netdevice.h>
+#include <linux/spinlock.h>
+#include <net/mac802154.h>
+#include <net/wpan-phy.h>
+
+static int numlbs = 1;
+
+struct fakelb_dev_priv {
+ struct ieee802154_dev *dev;
+
+ struct list_head list;
+ struct fakelb_priv *fake;
+
+ unsigned int working:1;
+};
+
+struct fakelb_priv {
+ struct list_head list;
+ rwlock_t lock;
+};
+
+static int
+fakelb_hw_ed(struct ieee802154_dev *dev, u8 *level)
+{
+ pr_debug("(%s)\n", __func__);
+
+ might_sleep();
+ BUG_ON(!level);
+ *level = 0xbe;
+
+ return 0;
+}
+
+static int
+fakelb_hw_channel(struct ieee802154_dev *dev, int page, int channel)
+{
+ pr_debug("(%s): set channel %d\n", __func__, channel);
+
+ might_sleep();
+ dev->phy->current_page = page;
+ dev->phy->current_channel = channel;
+
+ return 0;
+}
+
+static void
+fakelb_hw_deliver(struct fakelb_dev_priv *priv, struct sk_buff *skb)
+{
+ struct sk_buff *newskb;
+
+ if (!priv->working)
+ return;
+
+ newskb = pskb_copy(skb, GFP_ATOMIC);
+
+ ieee802154_rx_irqsafe(priv->dev, newskb, 0xcc);
+}
+
+static int
+fakelb_hw_xmit(struct ieee802154_dev *dev, struct sk_buff *skb)
+{
+ struct fakelb_dev_priv *priv = dev->priv;
+ struct fakelb_priv *fake = priv->fake;
+
+ might_sleep();
+
+ read_lock_bh(&fake->lock);
+ if (priv->list.next == priv->list.prev) {
+ /* we are the only one device */
+ fakelb_hw_deliver(priv, skb);
+ } else {
+ struct fakelb_dev_priv *dp;
+ list_for_each_entry(dp, &priv->fake->list, list)
+ if (dp != priv &&
+ dp->dev->phy->current_channel ==
+ priv->dev->phy->current_channel)
+ fakelb_hw_deliver(dp, skb);
+ }
+ read_unlock_bh(&fake->lock);
+
+ return 0;
+}
+
+static int
+fakelb_hw_start(struct ieee802154_dev *dev) {
+ struct fakelb_dev_priv *priv = dev->priv;
+
+ if (priv->working)
+ return -EBUSY;
+
+ priv->working = 1;
+
+ return 0;
+}
+
+static void
+fakelb_hw_stop(struct ieee802154_dev *dev) {
+ struct fakelb_dev_priv *priv = dev->priv;
+
+ priv->working = 0;
+}
+
+static struct ieee802154_ops fakelb_ops = {
+ .owner = THIS_MODULE,
+ .xmit = fakelb_hw_xmit,
+ .ed = fakelb_hw_ed,
+ .set_channel = fakelb_hw_channel,
+ .start = fakelb_hw_start,
+ .stop = fakelb_hw_stop,
+};
+
+/* Number of dummy devices to be set up by this module. */
+module_param(numlbs, int, 0);
+MODULE_PARM_DESC(numlbs, " number of pseudo devices");
+
+static int fakelb_add_one(struct device *dev, struct fakelb_priv *fake)
+{
+ struct fakelb_dev_priv *priv;
+ int err;
+ struct ieee802154_dev *ieee;
+
+ ieee = ieee802154_alloc_device(sizeof(*priv), &fakelb_ops);
+ if (!ieee)
+ return -ENOMEM;
+
+ priv = ieee->priv;
+ priv->dev = ieee;
+
+ /* 868 MHz BPSK 802.15.4-2003 */
+ ieee->phy->channels_supported[0] |= 1;
+ /* 915 MHz BPSK 802.15.4-2003 */
+ ieee->phy->channels_supported[0] |= 0x7fe;
+ /* 2.4 GHz O-QPSK 802.15.4-2003 */
+ ieee->phy->channels_supported[0] |= 0x7FFF800;
+ /* 868 MHz ASK 802.15.4-2006 */
+ ieee->phy->channels_supported[1] |= 1;
+ /* 915 MHz ASK 802.15.4-2006 */
+ ieee->phy->channels_supported[1] |= 0x7fe;
+ /* 868 MHz O-QPSK 802.15.4-2006 */
+ ieee->phy->channels_supported[2] |= 1;
+ /* 915 MHz O-QPSK 802.15.4-2006 */
+ ieee->phy->channels_supported[2] |= 0x7fe;
+ /* 2.4 GHz CSS 802.15.4a-2007 */
+ ieee->phy->channels_supported[3] |= 0x3fff;
+ /* UWB Sub-gigahertz 802.15.4a-2007 */
+ ieee->phy->channels_supported[4] |= 1;
+ /* UWB Low band 802.15.4a-2007 */
+ ieee->phy->channels_supported[4] |= 0x1e;
+ /* UWB High band 802.15.4a-2007 */
+ ieee->phy->channels_supported[4] |= 0xffe0;
+ /* 750 MHz O-QPSK 802.15.4c-2009 */
+ ieee->phy->channels_supported[5] |= 0xf;
+ /* 750 MHz MPSK 802.15.4c-2009 */
+ ieee->phy->channels_supported[5] |= 0xf0;
+ /* 950 MHz BPSK 802.15.4d-2009 */
+ ieee->phy->channels_supported[6] |= 0x3ff;
+ /* 950 MHz GFSK 802.15.4d-2009 */
+ ieee->phy->channels_supported[6] |= 0x3ffc00;
+
+
+ INIT_LIST_HEAD(&priv->list);
+ priv->fake = fake;
+
+ ieee->parent = dev;
+
+ err = ieee802154_register_device(ieee);
+ if (err)
+ goto err_reg;
+
+ write_lock_bh(&fake->lock);
+ list_add_tail(&priv->list, &fake->list);
+ write_unlock_bh(&fake->lock);
+
+ return 0;
+
+err_reg:
+ ieee802154_free_device(priv->dev);
+ return err;
+}
+
+static void fakelb_del(struct fakelb_dev_priv *priv)
+{
+ write_lock_bh(&priv->fake->lock);
+ list_del(&priv->list);
+ write_unlock_bh(&priv->fake->lock);
+
+ ieee802154_unregister_device(priv->dev);
+ ieee802154_free_device(priv->dev);
+}
+
+static int __devinit fakelb_probe(struct platform_device *pdev)
+{
+ struct fakelb_priv *priv;
+ struct fakelb_dev_priv *dp;
+ int err = -ENOMEM, i;
+
+ priv = kzalloc(sizeof(struct fakelb_priv), GFP_KERNEL);
+ if (!priv)
+ goto err_alloc;
+
+ INIT_LIST_HEAD(&priv->list);
+ rwlock_init(&priv->lock);
+
+ for (i = 0; i < numlbs; i++) {
+ err = fakelb_add_one(&pdev->dev, priv);
+ if (err < 0)
+ goto err_slave;
+ }
+
+ platform_set_drvdata(pdev, priv);
+ dev_info(&pdev->dev, "added ieee802154 hardware\n");
+ return 0;
+
+err_slave:
+ list_for_each_entry(dp, &priv->list, list)
+ fakelb_del(dp);
+ kfree(priv);
+err_alloc:
+ return err;
+}
+
+static int __devexit fakelb_remove(struct platform_device *pdev)
+{
+ struct fakelb_priv *priv = platform_get_drvdata(pdev);
+ struct fakelb_dev_priv *dp, *temp;
+
+ list_for_each_entry_safe(dp, temp, &priv->list, list)
+ fakelb_del(dp);
+ kfree(priv);
+
+ return 0;
+}
+
+static struct platform_device *ieee802154fake_dev;
+
+static struct platform_driver ieee802154fake_driver = {
+ .probe = fakelb_probe,
+ .remove = __devexit_p(fakelb_remove),
+ .driver = {
+ .name = "ieee802154fakelb",
+ .owner = THIS_MODULE,
+ },
+};
+
+static __init int fakelb_init_module(void)
+{
+ ieee802154fake_dev = platform_device_register_simple(
+ "ieee802154fakelb", -1, NULL, 0);
+ return platform_driver_register(&ieee802154fake_driver);
+}
+
+static __exit void fake_remove_module(void)
+{
+ platform_driver_unregister(&ieee802154fake_driver);
+ platform_device_unregister(ieee802154fake_dev);
+}
+
+module_init(fakelb_init_module);
+module_exit(fake_remove_module);
+MODULE_LICENSE("GPL");
+MODULE_AUTHOR("Dmitry Eremin-Solenikov, Sergey Lapin");
--
1.7.2.3
------------------------------------------------------------------------------
Learn Windows Azure Live! Tuesday, Dec 13, 2011
Microsoft is holding a special Learn Windows Azure training event for
developers. It will provide a great way to learn Windows Azure and what it
provides. You can attend the event by watching it streamed LIVE online.
Learn more at http://p.sf.net/sfu/ms-windowsazure
^ permalink raw reply related
* Re: [PATCH 01/11] SYSCTL: export root and set handling routines
From: Eric W. Biederman @ 2011-12-19 16:37 UTC (permalink / raw)
To: Stanislav Kinsbursky
Cc: Trond.Myklebust@netapp.com, linux-nfs@vger.kernel.org,
Pavel Emelianov, neilb@suse.de, netdev@vger.kernel.org,
linux-kernel@vger.kernel.org, James Bottomley,
bfields@fieldses.org, davem@davemloft.net, devel@openvz.org
In-Reply-To: <4EEF2C9A.8000403-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org>
Stanislav Kinsbursky <skinsbursky-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org> writes:
>> In practice what this means is that register_net_sysctl_table should
>> work for any sysctl file anywhere under /proc/sys. I think
>> register_net_sysctl_table is the right solution for your problem. The
>> only possible caveat I can think of is you might hit Al's performance
>> optimizations and need to create a common empty directory first with
>> register_sysctl_paths.
>
> Sorry, but I forgot to mention one more important goal I would like to achieve:
> I want to manage sysctl's variables in context of mount owner, but not viewer one.
> IOW imagine, that we have one two network namespaces: "A" and "B". Both of them
> have it's own net sysctl's root. And we have per-net sysctl "/proc/sys/var".
> And for ns "A" variable was set to 0, and for "B" - to 1.
> And B's "/proc/sys/var" is accessible from "A" namespace
> ("/chroot_path/proc/sys/var" for example).
> With this configuration I want to read "1" from both namespaces:
> owner "B" (/proc/sys/var) and "A" ("/chroot_path/proc/sys/var").
> Looks like simple using of register_net_sysctl_table doesn't allow me this,
> because current net ns is used. And to achieve this goal I need my own sysctl
> set for SUNRPC like it was done for network namespaces.
Doing that independently of the rest of the sysctls is pretty horrible
and confusing to users. What I am planning might suit your needs and
if not we need to talk some more about how to get the vfs to do
something reasonable.
>> That said since I am in the process of rewriting things some of this
>> may change a little bit, but hopefully not in ways that immediately
>> effect the users of register_sysctl_table.
>>
>> Don't use register_net_sysctl_ro_table. I think what the implementors
>> actually wanted was register_net_sysctl_table(&init_net, ...) and didn't
>> know it.
>>
>> Don't put subdirectories in your sysctl tables. Use a ctl_path to
>> specify the entire directory where the files should show up. Generally
>> the code is easier to read in that form, and the code is simpler to deal
>> with if we don't have to worry about directories.
>>
>> Don't play with the sysctl roots. It is my intention to completely kill
>> them off and replace them by moving the per net sysctl tree under
>> /proc/<pid>/sys/. Leaving behind symlinks in /proc/sys/net and I guess
>> ultimately in /proc/sys/sunrpc/ and /proc/sys/fs/nfs... Which actually
>> seems to better describe your mental model.
>>
>
>
> I'm afraid, that this approach this not allow me to achieve the goal, mentioned
> above, because current->nsproxy->net_ns will be used during lookup.
> Or maybe I misunderstanding here?
What I hope to do is to stop using current, and to behave like
/proc/net. Aka a per process view under /proc/<pid>/sys that matches
the namespaces of the specified process.
The VFS really hates my use of current in the sysctl case, and I intend
to stop.
I need to run and catch my plane. It doesn't look like I will have
access to this email address for the next two weeks :(
Eric
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH v2] ARM: net: JIT compiler for packet filters
From: Mircea Gherzan @ 2011-12-19 16:45 UTC (permalink / raw)
To: Dave Martin; +Cc: linux-arm-kernel, netdev
In-Reply-To: <20111219125021.GA2031@linaro.org>
Hi,
On Mon, Dec 19, 2011 at 12:50:21PM +0000, Dave Martin wrote:
> On Mon, Dec 19, 2011 at 09:40:30AM +0100, Mircea Gherzan wrote:
> > Based of Matt Evans's PPC64 implementation.
> >
> > Supports only ARM mode with EABI.
> >
> > Supports both little and big endian. Depends on the support for
> > unaligned loads on ARMv7. Does not support all the BPF opcodes
> > that deal with ancillary data. The scratch memory of the filter
> > lives on the stack.
> >
> > Enabled in the same way as for x86-64 and PPC64:
> >
> > echo 1 > /proc/sys/net/core/bpf_jit_enable
> >
> > A value greater than 1 enables opcode output.
> >
> > Signed-off-by: Mircea Gherzan <mgherzan@gmail.com>
> > ---
>
> Interesting patch... I haven't reviewed in detail, but I have a few
> quick comments.
>
> >
> > Changes in v2:
> > * enable the compiler ony for ARMv5+ because of the BLX instruction
> > * use the same comparison for the ARM version checks
> > * use misaligned accesses on ARMv6
>
> You probably want to change the commit message now to reflect this.
Will do in the next version.
>
> > * fix the SEEN_MEM
> > * fix the mem_words_used()
> >
> > arch/arm/Kconfig | 1 +
> > arch/arm/Makefile | 1 +
> > arch/arm/net/Makefile | 3 +
> > arch/arm/net/bpf_jit_32.c | 838 +++++++++++++++++++++++++++++++++++++++++++++
> > arch/arm/net/bpf_jit_32.h | 174 ++++++++++
> > 5 files changed, 1017 insertions(+), 0 deletions(-)
> > create mode 100644 arch/arm/net/Makefile
> > create mode 100644 arch/arm/net/bpf_jit_32.c
> > create mode 100644 arch/arm/net/bpf_jit_32.h
> >
> > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > index abba5b8..ea65c41 100644
> > --- a/arch/arm/Kconfig
> > +++ b/arch/arm/Kconfig
> > @@ -30,6 +30,7 @@ config ARM
> > select HAVE_SPARSE_IRQ
> > select GENERIC_IRQ_SHOW
> > select CPU_PM if (SUSPEND || CPU_IDLE)
> > + select HAVE_BPF_JIT if (!THUMB2_KERNEL && AEABI)
>
> Have to tried your code with a Thumb-2 kernel?
Not yet.
> Quickly skimming though your patch, I don't see an obvious reason why we
> can't have that working, though I haven't tried it yet.
>
> Note that it's fine to have the JIT generating ARM code, even if the rest
> if the kernel is Thumb-2. This would only start to cause problems if we
> want to do things like set kprobes in the JITted code, or unwind out of
> the JITted code.
>
> It's just necessary to make sure that calls/returns into/out of the
> JITted code are handled correctly. You don't seem to do any scary
> arithmetic or mov to or from pc or lr, and it doesn't look like you ever
> call back into the kernel from JITted code, so the implementation is
> probably safe for ARM/Thumb interworking already (if I've understood
> correctly).
The JITed code calls back to the kernel for the load helpers. So setting
bit 0 is required.
> It doesn't look hard to port the JIT to generate Thumb-2 code directly
> either -- but I suggest not to worry about that initially. So long as
> the ARM-based JIT works in a Thumb-2 kernel, it will be useful.
>
> [...]
>
> > diff --git a/arch/arm/net/bpf_jit_32.c b/arch/arm/net/bpf_jit_32.c
> > new file mode 100644
> > index 0000000..d2b86fa
> > --- /dev/null
> > +++ b/arch/arm/net/bpf_jit_32.c
>
> [...]
>
> > +static int build_body(struct jit_ctx *ctx)
> > +{
>
> [...]
>
> > + case BPF_S_ALU_DIV_K:
> > + /* K is not zero, it was previously checked */
> > + emit_mov_i(ARM_R1, k, ctx);
> > + goto div;
> > + case BPF_S_ALU_DIV_X:
> > + ctx->seen |= SEEN_X;
> > + emit(ARM_CMP_I(r_X, 0), ctx);
> > + emit_err_ret(ARM_COND_EQ, ctx);
> > + emit(ARM_MOV_R(ARM_R1, r_X), ctx);
> > +div:
> > + ctx->seen |= SEEN_CALL;
> > +
> > + emit(ARM_MOV_R(ARM_R0, r_A), ctx);
> > + emit_mov_i(r_scratch, (u32)__aeabi_uidiv, ctx);
> > + emit(ARM_BLX_R(r_scratch), ctx);
> > + emit(ARM_MOV_R(r_A, ARM_R0), ctx);
> > + break;
>
> I don't know how much division is used by the packet filter JIT. If
> it gets used a significant amount, you might want to support hardware
> divide for CPUs that have it:
Division rarely appears in "normal" BPF filters: it must be an explicit
part of the human-readable filter expression (the BPF compiler does not
generate division opcodes in other cases, AFAICT). Nonetheless, support
for hardware division would spare a bit of stack space for filters like
"len / 100 == 1".
> Cortex-A15 and later processors may have hardware integer divide
> support. You can check for its availability at runtime using by testing
> the HWCAP_IDIVA (for ARM) or HWCAP_IDIVT (for Thumb) bits in elf_hwcap
> (see arch/arm/include/asm/hwcap.h).
I will include this in the next version of the patch.
Cheers,
Mircea
^ permalink raw reply
* Re: netem and hierarchical ingress traffic shaping
From: John A. Sullivan III @ 2011-12-19 16:53 UTC (permalink / raw)
To: Stephen Hemminger; +Cc: netdev
In-Reply-To: <20111218115549.0d9e1259@nehalam.linuxnetplumber.net>
On Sun, 2011-12-18 at 11:55 -0800, Stephen Hemminger wrote:
> On Sun, 18 Dec 2011 00:12:12 -0500
> "John A. Sullivan III" <jsullivan@opensourcedevel.com> wrote:
>
> > Since netem appears to be classless, we realized we would need to
> > replace the SFQ on each leaf with netem which we really didn't want to
> > do - not only to not lose SFQ but because we didn't want to maintain the
> > netem parameters on each leaf. So, we activated our ifb1 interface,
> > placed netem on it and redirected all the egress traffic to ifb1. Taht
> > worked fine.
>
> Current versions of netem can take one class.
<snip>
Thanks but how would that work? For example, I assume we could not send
netem processed packets to SFQ because SFQ is classless. We tried
anyway and got:
root@testswitch01:~# tc class add dev ifb0 parent 1201: classid 1202 sfq
perturb 60
Error: Qdisc "sfq" is classless.
root@testswitch01:~# tc qdisc add dev ifb0 parent 1201: handle 1202 sfq
perturb 60
RTNETLINK answers: Operation not supported
1201 is a netem qdisc at the end of hfsc.
Not being quite sure what you meant, we thought we experiment before
asking so we tried to attach an hfsc class to the netem qdisc. We
didn't think it would work and it didn't:
root@testswitch01:~# tc qdisc add dev eth3 root handle 7 netem delay
25ms 5ms distribution normal loss 0.1% 30%
root@testswitch01:~# tc class add dev eth3 parent 7: classid 7:1 hfsc sc
rate 1490kbit ul rate 1490kbit
RTNETLINK answers: Invalid argument
So we tried adding the hfsc qdisc first:
root@testswitch01:~# tc qdisc add dev eth3 parent 7: handle 7:1 hfsc
default 70
RTNETLINK answers: File exists
Then, just for kicks, we tried adding an SFQ qdisc in case the problem
with the previous attempts was that the netem qdisc was not at the top
level:
root@testswitch01:~# tc qdisc add dev eth3 parent 7: handle 7:1 sfq
perturb 60
RTNETLINK answers: File exists
So I'm still not sure how we can do anything other than stick netem on
the end of one of our branches or at root. Thanks - John
^ permalink raw reply
* Re: [PATCH v2] ARM: net: JIT compiler for packet filters
From: Mircea Gherzan @ 2011-12-19 17:14 UTC (permalink / raw)
To: Dave Martin; +Cc: linux-arm-kernel, netdev
In-Reply-To: <20111219155252.GG2031@linaro.org>
Hi,
On Mon, Dec 19, 2011 at 03:52:52PM +0000, Dave Martin wrote:
> On Mon, Dec 19, 2011 at 04:33:38PM +0100, Uwe Kleine-K?nig wrote:
> > Hello,
> >
> > On Mon, Dec 19, 2011 at 03:24:18PM +0000, Dave Martin wrote:
> > > On Mon, Dec 19, 2011 at 04:19:58PM +0100, Uwe Kleine-K?nig wrote:
> > > > On Mon, Dec 19, 2011 at 12:50:21PM +0000, Dave Martin wrote:
> > > > > On Mon, Dec 19, 2011 at 09:40:30AM +0100, Mircea Gherzan wrote:
> > > > > > Based of Matt Evans's PPC64 implementation.
> > > > > Note that it's fine to have the JIT generating ARM code, even if the rest
> > > > > if the kernel is Thumb-2. This would only start to cause problems if we
> > > > > want to do things like set kprobes in the JITted code, or unwind out of
> > > > > the JITted code.
> > > > or use a CPU that doesn't speak ARM (e.g. v7M)
> > >
> > > Indeed... I was assuming though that that would be out of scope for the
> > > first iteration of this code.
> > Right, depending on !THUMB2 is fine. Only generating ARM code with
> > THUMB2=y is not.
>
> The kernel doesn't support v7-M upstream though. CONFIG_THUMB2_KERNEL=y
> doesn't mean that there is no ARM code present -- there _is_ ARM code in
> the kernel image even with this option (though not very much).
What about relying at runtime on bits[3:0] of ID_PFR0? And this only for
ARMv7.
Are there any other ARM cores of interest that do _not_ support the ARM
instruction set?
Thanks,
Mircea
^ permalink raw reply
* Re: [PATCH 01/11] SYSCTL: export root and set handling routines
From: Stanislav Kinsbursky @ 2011-12-19 17:24 UTC (permalink / raw)
To: Eric W. Biederman
Cc: Trond.Myklebust-HgOvQuBEEgTQT0dZR+AlfA@public.gmane.org,
linux-nfs-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
Pavel Emelianov, neilb-l3A5Bk7waGM@public.gmane.org,
netdev-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
linux-kernel-u79uwXL29TY76Z2rM5mHXA@public.gmane.org,
James Bottomley, bfields-uC3wQj2KruNg9hUCZPvPmw@public.gmane.org,
davem-fT/PcQaiUtIeIZ0/mPfg9Q@public.gmane.org,
devel-GEFAQzZX7r8dnm+yROfE0A@public.gmane.org
In-Reply-To: <m1pqfkecw0.fsf-+imSwln9KH6u2/kzUuoCbdi2O/JbrIOy@public.gmane.org>
19.12.2011 20:37, Eric W. Biederman пишет:
> Stanislav Kinsbursky<skinsbursky-bzQdu9zFT3WakBO8gow8eQ@public.gmane.org> writes:
>
> Doing that independently of the rest of the sysctls is pretty horrible
> and confusing to users. What I am planning might suit your needs and
> if not we need to talk some more about how to get the vfs to do
> something reasonable.
>
Ok, Eric. Would be glad to discuss your sysctls plans.
But actually you already know my needs: I would like to make sysctls work in the
way like sysfs does: i.e. content of files depends on mount maker - not viewer.
--
Best regards,
Stanislav Kinsbursky
--
To unsubscribe from this list: send the line "unsubscribe linux-nfs" in
the body of a message to majordomo-u79uwXL29TY76Z2rM5mHXA@public.gmane.org
More majordomo info at http://vger.kernel.org/majordomo-info.html
^ permalink raw reply
* Re: [PATCH] ARM: net: JIT compiler for packet filters
From: Nicolas Pitre @ 2011-12-19 17:31 UTC (permalink / raw)
To: Rob Herring; +Cc: Mircea Gherzan, netdev, linux-arm-kernel
In-Reply-To: <4EEEA644.5010008@gmail.com>
On Sun, 18 Dec 2011, Rob Herring wrote:
> On 12/18/2011 05:49 PM, Mircea Gherzan wrote:
> > + select HAVE_BPF_JIT if (!THUMB2_KERNEL && AEABI)
>
> No thumb2. That's a shame...
I think this would be more sensible to make a Thumb2 kernel properly
interoperate with this and keep the JIT code simple rather than having
to duplicate all this for Thumb2.
> BLX is v5+ only. It probably fine to make the JIT v5+ only. There's
> probably not much v4 h/w that would use this.
While you might be right, I don't think it is that big a cost to make
this support ARMv4 too. In fact, if slow ARMv4 systems are still
routing packets out there, they are likely to see a huge benefit from
this.
Nicolas
^ permalink raw reply
* Re: [PATCH v2] ARM: net: JIT compiler for packet filters
From: Catalin Marinas @ 2011-12-19 17:39 UTC (permalink / raw)
To: Dave Martin; +Cc: Uwe Kleine-K?nig, Mircea Gherzan, linux-arm-kernel, netdev
In-Reply-To: <20111219155252.GG2031@linaro.org>
On 19 December 2011 15:52, Dave Martin <dave.martin@linaro.org> wrote:
> On Mon, Dec 19, 2011 at 04:33:38PM +0100, Uwe Kleine-K?nig wrote:
>> On Mon, Dec 19, 2011 at 03:24:18PM +0000, Dave Martin wrote:
>> > On Mon, Dec 19, 2011 at 04:19:58PM +0100, Uwe Kleine-K?nig wrote:
>> > > On Mon, Dec 19, 2011 at 12:50:21PM +0000, Dave Martin wrote:
>> > > > On Mon, Dec 19, 2011 at 09:40:30AM +0100, Mircea Gherzan wrote:
>> > > > > Based of Matt Evans's PPC64 implementation.
>> > > > Note that it's fine to have the JIT generating ARM code, even if the rest
>> > > > if the kernel is Thumb-2. This would only start to cause problems if we
>> > > > want to do things like set kprobes in the JITted code, or unwind out of
>> > > > the JITted code.
>> > > or use a CPU that doesn't speak ARM (e.g. v7M)
>> >
>> > Indeed... I was assuming though that that would be out of scope for the
>> > first iteration of this code.
>> Right, depending on !THUMB2 is fine. Only generating ARM code with
>> THUMB2=y is not.
>
> The kernel doesn't support v7-M upstream though. CONFIG_THUMB2_KERNEL=y
> doesn't mean that there is no ARM code present -- there _is_ ARM code in
> the kernel image even with this option (though not very much).
>
> IMHO, CONFIG_THUMB2_KERNEL should be viewed as similiar to an optimisation
> option or other code gen options -- it's a hint to use the Thumb-2
> instruction set in preference to ARM, but doesn't make a 100% guarantee.
> Some parts of the kernel do contain ARM code even in this configuration.
>
>
> The real problem we have here is that we do not distinguish between v7-A
> and v7-M in Kconfig (this is not the same thing as CONFIG_MMU, since
> there's no special reason why it should be impossible to build a ucLinux
> kernel for v7-A -- in which case the ARM instruction is available)
If we ever take the time to push ARMv7-M into mainline, my patches
actually introduce CONFIG_CPU_V7M:
http://www.linux-arm.org/git?p=linux-2.6-stable.git;a=commitdiff;h=53a9ca6eccb3e14c7d9045870464cbfb37b0bb3b
--
Catalin
^ permalink raw reply
* UNITED NATIONS COMMISION
From: UNITED NATIONS COMMISSION @ 2011-12-19 16:14 UTC (permalink / raw)
[-- Attachment #1: Type: text/plain, Size: 132 bytes --]
Dear Sir/Madam
Please open the attached message and get back to us for the processing of your payment.
Thanks
Mrs. Else Mueller
[-- Attachment #2: UNITED NATIONS COMMISION.rtf --]
[-- Type: application/octet-stream, Size: 4783 bytes --]
^ permalink raw reply
* Re: [PATCH] ARM: net: JIT compiler for packet filters
From: Nicolas Pitre @ 2011-12-19 17:42 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: linux-arm-kernel, netdev
In-Reply-To: <1324252185-15894-1-git-send-email-mgherzan@gmail.com>
On Mon, 19 Dec 2011, Mircea Gherzan wrote:
> +static inline void _emit(int cond, u32 inst, struct jit_ctx *ctx)
> +{
> + if (ctx->target != NULL)
> + ctx->target[ctx->idx] = inst | (cond << 28);
> +
> + ctx->idx++;
> +}
You might consider the patch titled "ARM: Add generic instruction opcode
manipulation helpers" that Dave Martin just posted and rely on it to
make your code compatible with BE8 mode as well.
Also it seems that you are making the distinction between pre-ARMv7 and
ARMv7+ while in most cases it should be pre-ARMv6 and ARMv6+
Nicolas
^ permalink raw reply
* Re: [PATCH v2] ARM: net: JIT compiler for packet filters
From: Dave Martin @ 2011-12-19 18:18 UTC (permalink / raw)
To: Mircea Gherzan; +Cc: linux-arm-kernel, netdev
In-Reply-To: <20111219164513.GA25105@swarm.cs.pub.ro>
On Mon, Dec 19, 2011 at 06:45:13PM +0200, Mircea Gherzan wrote:
> Hi,
>
> On Mon, Dec 19, 2011 at 12:50:21PM +0000, Dave Martin wrote:
> > On Mon, Dec 19, 2011 at 09:40:30AM +0100, Mircea Gherzan wrote:
> > > Based of Matt Evans's PPC64 implementation.
> > >
> > > Supports only ARM mode with EABI.
> > >
> > > Supports both little and big endian. Depends on the support for
> > > unaligned loads on ARMv7. Does not support all the BPF opcodes
> > > that deal with ancillary data. The scratch memory of the filter
> > > lives on the stack.
> > >
> > > Enabled in the same way as for x86-64 and PPC64:
> > >
> > > echo 1 > /proc/sys/net/core/bpf_jit_enable
> > >
> > > A value greater than 1 enables opcode output.
> > >
> > > Signed-off-by: Mircea Gherzan <mgherzan@gmail.com>
> > > ---
> >
> > Interesting patch... I haven't reviewed in detail, but I have a few
> > quick comments.
> >
> > >
> > > Changes in v2:
> > > * enable the compiler ony for ARMv5+ because of the BLX instruction
> > > * use the same comparison for the ARM version checks
> > > * use misaligned accesses on ARMv6
> >
> > You probably want to change the commit message now to reflect this.
>
> Will do in the next version.
>
> >
> > > * fix the SEEN_MEM
> > > * fix the mem_words_used()
> > >
> > > arch/arm/Kconfig | 1 +
> > > arch/arm/Makefile | 1 +
> > > arch/arm/net/Makefile | 3 +
> > > arch/arm/net/bpf_jit_32.c | 838 +++++++++++++++++++++++++++++++++++++++++++++
> > > arch/arm/net/bpf_jit_32.h | 174 ++++++++++
> > > 5 files changed, 1017 insertions(+), 0 deletions(-)
> > > create mode 100644 arch/arm/net/Makefile
> > > create mode 100644 arch/arm/net/bpf_jit_32.c
> > > create mode 100644 arch/arm/net/bpf_jit_32.h
> > >
> > > diff --git a/arch/arm/Kconfig b/arch/arm/Kconfig
> > > index abba5b8..ea65c41 100644
> > > --- a/arch/arm/Kconfig
> > > +++ b/arch/arm/Kconfig
> > > @@ -30,6 +30,7 @@ config ARM
> > > select HAVE_SPARSE_IRQ
> > > select GENERIC_IRQ_SHOW
> > > select CPU_PM if (SUSPEND || CPU_IDLE)
> > > + select HAVE_BPF_JIT if (!THUMB2_KERNEL && AEABI)
> >
> > Have to tried your code with a Thumb-2 kernel?
>
> Not yet.
>
> > Quickly skimming though your patch, I don't see an obvious reason why we
> > can't have that working, though I haven't tried it yet.
> >
> > Note that it's fine to have the JIT generating ARM code, even if the rest
> > if the kernel is Thumb-2. This would only start to cause problems if we
> > want to do things like set kprobes in the JITted code, or unwind out of
> > the JITted code.
> >
> > It's just necessary to make sure that calls/returns into/out of the
> > JITted code are handled correctly. You don't seem to do any scary
> > arithmetic or mov to or from pc or lr, and it doesn't look like you ever
> > call back into the kernel from JITted code, so the implementation is
> > probably safe for ARM/Thumb interworking already (if I've understood
> > correctly).
>
> The JITed code calls back to the kernel for the load helpers. So setting
> bit 0 is required.
When you take the address of a link-time external function symbol,
bit[0] in the address will automatically be set appropriately by the
linker to indicate the target instruction set -- you already use BX/BLX
to jump to such symbols, so you should switch correctly when calling
_to_ the kernel.
Returns should also work, except for old-style "mov pc,lr" returns made
in Thumb code (from ARM code, this magically works for >= v7). Such returns
only happen in hand-written assembler: for C code, the compiler always
generates proper AEABI-compliant return sequences.
So, for calling load_func[], jit_get_skb_b etc. (which are C functions),
there should be no problem.
I think the only code which you call from the JIT output but which does
not return compliantly is __aeabi_uidiv() in arch/arm/lib/lib1funcs.S.
I have a quick hacked-up patch (below) which attempts to fix this;
I'd be interested if this works for you -- but finalising your ARM-only
version of the patch should still be the priority.
If this fix does work, I'll turn it into a proper patch, as we can maybe
use it more widely.
[...]
> > > + case BPF_S_ALU_DIV_X:
> > > + ctx->seen |= SEEN_X;
> > > + emit(ARM_CMP_I(r_X, 0), ctx);
> > > + emit_err_ret(ARM_COND_EQ, ctx);
> > > + emit(ARM_MOV_R(ARM_R1, r_X), ctx);
> > > +div:
> > > + ctx->seen |= SEEN_CALL;
> > > +
> > > + emit(ARM_MOV_R(ARM_R0, r_A), ctx);
> > > + emit_mov_i(r_scratch, (u32)__aeabi_uidiv, ctx);
> > > + emit(ARM_BLX_R(r_scratch), ctx);
> > > + emit(ARM_MOV_R(r_A, ARM_R0), ctx);
> > > + break;
> >
> > I don't know how much division is used by the packet filter JIT. If
> > it gets used a significant amount, you might want to support hardware
> > divide for CPUs that have it:
>
> Division rarely appears in "normal" BPF filters: it must be an explicit
> part of the human-readable filter expression (the BPF compiler does not
> generate division opcodes in other cases, AFAICT). Nonetheless, support
> for hardware division would spare a bit of stack space for filters like
> "len / 100 == 1".
>
> > Cortex-A15 and later processors may have hardware integer divide
> > support. You can check for its availability at runtime using by testing
> > the HWCAP_IDIVA (for ARM) or HWCAP_IDIVT (for Thumb) bits in elf_hwcap
> > (see arch/arm/include/asm/hwcap.h).
>
> I will include this in the next version of the patch.
Ok, cool
Cheers
---Dave
^ permalink raw reply
page: next (older) | prev (newer) | latest
- recent:[subjects (threaded)|topics (new)|topics (active)]
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox